Skip to content

Instantly share code, notes, and snippets.

View Charmatzis's full-sized avatar
🎯
Focusing

Christos Charmatzis

🎯
Focusing
View GitHub Profile
@Charmatzis
Charmatzis / psql_useful_stat_queries.psql
Last active May 26, 2021 08:40
List of some useful Stat Queries for PSQL
-- Unused Indexes
select
indexrelname as index_name,
idx_scan,
idx_tup_read,
idx_tup_fetch
from
pg_stat_all_indexes
where
idx_scan = 0
SELECT c.conrelid::regclass AS "table",
/* list of key column names in order */
string_agg(a.attname, ',' ORDER BY x.n) AS columns,
pg_catalog.pg_size_pretty(
pg_catalog.pg_relation_size(c.conrelid)
) AS size,
c.conname AS constraint,
c.confrelid::regclass AS referenced_table
FROM pg_catalog.pg_constraint c
/* enumerated key column numbers per foreign key */

Reading tiles using RIO

<GDAL_WMS>
    <Service name="TMS">
	<ServerUrl>https://api.mapbox.com/v4/mapbox.satellite/${z}/${x}/${y}.jpg?access_token=******</ServerUrl> <!-- Map -->
    </Service>
    <DataWindow>
        <UpperLeftX>-20037508.34</UpperLeftX>
 20037508.34
@Charmatzis
Charmatzis / info.json
Created March 6, 2019 09:54
TileJSON.io - MarineTraffic Density Maps 2016-2017Ship traffic 2016-2017 map comparison
{
"baseLayer": {
"tilejson": "2.2.0",
"name": "base",
"version": "1.0.0",
"scheme": "xyz",
"tiles": [
"https://a.tile.openstreetmap.org/{z}/{x}/{y}.png"
]
},
@Charmatzis
Charmatzis / index_physical_stats.sql
Created April 16, 2018 04:35
Get index_physical_stats from table in SQL Server
select index_id
, index_type_desc
, index_depth
, index_level
, page_count
, record_count
from sys.dm_db_index_physical_stats (DB_ID(),
OBJECT_ID('Table_Name'), DEFAULT, DEFAULT, 'DETAILED')
go
@Charmatzis
Charmatzis / allocated_page_page_id.sql
Created March 23, 2018 15:09
getallocated_page_page_id of a table MS SQL Server
WITH dataCTE
AS
(
SELECT allocated_page_page_id, next_page_page_id, previous_page_page_id
FROM sys.dm_db_database_page_allocations(DB_ID(), OBJECT_ID('dbo.TEMP_POS_TERR'),1, NULL, 'DETAILED')
WHERE is_allocated = 1
AND page_type_desc = 'DATA_PAGE'
)
,pageCTE
AS
@Charmatzis
Charmatzis / getsize.sql
Last active March 23, 2018 14:49
Get Table size in SQL Server
USE MyDatabase
GO
EXEC sp_spaceused N'User.ContactInfo'
GO
@Charmatzis
Charmatzis / sqlserver_cpu_usage.sql
Created March 9, 2018 07:01
SQL Server CPU Usage by Session
--http://blogs.lobsterpot.com.au/2018/02/13/sql-server-cpu-usage-by-session/
DECLARE @sessionsCPU TABLE
(
session_id SMALLINT NOT NULL,
cpu_time INT NULL ,
initialCPUFlag BIT NOT NULL
)
INSERT INTO @sessionsCPU
SELECT
@Charmatzis
Charmatzis / SQLServerGetVersion.sql
Created February 22, 2018 07:16
Get MS SQL Server edition details
SELECT
CASE
WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('productversion')) like '8%' THEN 'SQL2000'
WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('productversion')) like '9%' THEN 'SQL2005'
WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('productversion')) like '10.0%' THEN 'SQL2008'
WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('productversion')) like '10.5%' THEN 'SQL2008 R2'
WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('productversion')) like '11%' THEN 'SQL2012'
WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('productversion')) like '12%' THEN 'SQL2014'
WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('productversion')) like '13%' THEN 'SQL2016'
WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('productversion')) like '14%' THEN 'SQL2017'
@Charmatzis
Charmatzis / Zeppelin.md
Last active February 5, 2018 11:06
use Zeppelin in EMR with geotrellis and geotrellis-spark-sql

Introduction

This is a help page for settinh up Zeppelin with geotrellis and geotrellis-spark-sql and continue with analysis.

Steps

Prestep

Set properties for EMR cluster