-
-
Save dsaiztc/7a10912c4959c8782c1c94a3de5aac74 to your computer and use it in GitHub Desktop.
Revisions
-
iconara revised this gist
Apr 13, 2018 . 1 changed file with 7 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -203,4 +203,10 @@ SELECT HAS_TABLE_PRIVILEGE(users.user_name, full_object_name, 'delete') AS "delete", HAS_TABLE_PRIVILEGE(users.user_name, full_object_name, 'references') AS "references" FROM users, objects ORDER BY full_object_name; -- Find tables that need vacuum or analyze SELECT "database", "schema", "table", unsorted, stats_off FROM svv_table_info WHERE unsorted > 20 OR stats_off > 20 -
iconara revised this gist
Apr 13, 2018 . 1 changed file with 32 additions and 33 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -171,37 +171,36 @@ WHERE TRIM(status) = 'Running' AND event = 'initiating session'; -- Show permissions WITH users AS ( SELECT usename AS user_name FROM pg_user ), objects AS ( SELECT schemaname AS schema_name, 'table' AS object_type, tablename AS object_name, schemaname + '.' + tablename AS full_object_name FROM pg_tables WHERE schemaname NOT IN ('pg_internal') UNION SELECT schemaname AS schema_name, 'view' AS object_type, viewname AS object_name, schemaname + '.' + viewname AS full_object_name FROM pg_views WHERE schemaname NOT IN ('pg_internal') ) SELECT schema_name, object_name, object_type, user_name, HAS_TABLE_PRIVILEGE(users.user_name, full_object_name, 'select') AS "select", HAS_TABLE_PRIVILEGE(users.user_name, full_object_name, 'insert') AS "insert", HAS_TABLE_PRIVILEGE(users.user_name, full_object_name, 'update') AS "update", HAS_TABLE_PRIVILEGE(users.user_name, full_object_name, 'delete') AS "delete", HAS_TABLE_PRIVILEGE(users.user_name, full_object_name, 'references') AS "references" FROM users, objects ORDER BY full_object_name; -
iconara revised this gist
Apr 11, 2018 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -188,15 +188,15 @@ FROM ( ( SELECT schemaname AS schema_name, 'table' AS object_type, tablename AS object_name, schemaname + '.' + tablename AS full_object_name FROM pg_tables WHERE schemaname NOT IN ('pg_internal') UNION SELECT schemaname AS schema_name, 'view' AS object_type, viewname AS object_name, schemaname + '.' + viewname AS full_object_name FROM pg_views -
iconara revised this gist
Apr 11, 2018 . 1 changed file with 20 additions and 19 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -174,33 +174,34 @@ AND event = 'initiating session'; SELECT * FROM ( SELECT schema_name, object_name, object_type, user_name, HAS_TABLE_PRIVILEGE(users.user_name, full_object_name, 'select') AS "select", HAS_TABLE_PRIVILEGE(users.user_name, full_object_name, 'insert') AS "insert", HAS_TABLE_PRIVILEGE(users.user_name, full_object_name, 'update') AS "update", HAS_TABLE_PRIVILEGE(users.user_name, full_object_name, 'delete') AS "delete", HAS_TABLE_PRIVILEGE(users.user_name, full_object_name, 'references') AS "references" FROM (SELECT usename AS user_name FROM pg_user) AS users, ( SELECT schemaname AS schema_name, 't' AS object_type, tablename AS object_name, schemaname + '.' + tablename AS full_object_name FROM pg_tables WHERE schemaname NOT IN ('pg_internal') UNION SELECT schemaname AS schema_name, 'v' AS object_type, viewname AS object_name, schemaname + '.' + viewname AS full_object_name FROM pg_views WHERE schemaname NOT IN ('pg_internal') ) AS objects ORDER BY full_object_name ) WHERE ("select" OR "insert" OR "update" OR "delete" OR "references"); -
iconara revised this gist
Apr 11, 2018 . 1 changed file with 37 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -153,7 +153,7 @@ SELECT r.query AS sql FROM stv_recents r LEFT JOIN stv_inflight i ON r.pid = i.pid; -- Show the remote host and port of running queries SELECT recents.pid, TRIM(db_name) AS db, @@ -168,4 +168,39 @@ FROM stv_recents recents LEFT JOIN stl_connection_log connections ON (recents.pid = connections.pid) LEFT JOIN stv_inflight inflight ON recents.pid = inflight.pid WHERE TRIM(status) = 'Running' AND event = 'initiating session'; -- Show permissions SELECT * FROM ( SELECT schemaname AS "schema", objectname AS "object", usename AS "user", HAS_TABLE_PRIVILEGE(users.usename, fullobj, 'select') AS "select", HAS_TABLE_PRIVILEGE(users.usename, fullobj, 'insert') AS "insert", HAS_TABLE_PRIVILEGE(users.usename, fullobj, 'update') AS "update", HAS_TABLE_PRIVILEGE(users.usename, fullobj, 'delete') AS "delete", HAS_TABLE_PRIVILEGE(users.usename, fullobj, 'references') AS "references" FROM (SELECT * FROM pg_user) AS users, ( SELECT schemaname, 't' AS obj_type, tablename AS objectname, schemaname + '.' + tablename AS fullobj FROM pg_tables WHERE schemaname NOT IN ('pg_internal') UNION SELECT schemaname, 'v' AS obj_type, viewname AS objectname, schemaname + '.' + viewname AS fullobj FROM pg_views WHERE schemaname NOT IN ('pg_internal') ) AS objects ORDER BY fullobj ) WHERE ("select" OR "insert" OR "update" OR "delete" OR "references"); -
iconara revised this gist
Apr 24, 2016 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -143,14 +143,14 @@ ORDER BY 1, 2, 3, 4; -- Currently executing and recently executed queries with status, duration, database, etc. SELECT r.pid, TRIM(status) AS status, TRIM(db_name) AS db, TRIM(user_name) AS "user", TRIM(label) AS query_group, r.starttime AS start_time, r.duration, r.query AS sql FROM stv_recents r LEFT JOIN stv_inflight i ON r.pid = i.pid; -- See the remote host and port of running queries -
iconara revised this gist
Feb 19, 2016 . 1 changed file with 7 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -159,11 +159,13 @@ SELECT TRIM(db_name) AS db, TRIM(user_name) AS "user", TRIM(label) AS query_group, recents.starttime AS start_time, recents.duration, recents.query AS sql, TRIM(remotehost) AS remote_host, TRIM(remoteport) AS remote_port FROM stv_recents recents LEFT JOIN stl_connection_log connections ON (recents.pid = connections.pid) LEFT JOIN stv_inflight inflight ON recents.pid = inflight.pid WHERE TRIM(status) = 'Running' AND event = 'initiating session'; -
iconara revised this gist
Feb 19, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -155,7 +155,7 @@ FROM stv_recents r LEFT JOIN stv_inflight i ON r.pid = i.pid; -- See the remote host and port of running queries SELECT recents.pid, TRIM(db_name) AS db, TRIM(user_name) AS "user", TRIM(label) AS query_group, -
iconara revised this gist
Feb 19, 2016 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -143,6 +143,7 @@ ORDER BY 1, 2, 3, 4; -- Currently executing and recently executed queries with status, duration, database, etc. SELECT recent.pid, TRIM(status) AS status, TRIM(db_name) AS db, TRIM(user_name) AS "user", @@ -154,6 +155,7 @@ FROM stv_recents r LEFT JOIN stv_inflight i ON r.pid = i.pid; -- See the remote host and port of running queries SELECT recent.pid, TRIM(db_name) AS db, TRIM(user_name) AS "user", TRIM(label) AS query_group, -
iconara revised this gist
Feb 19, 2016 . 1 changed file with 7 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -144,13 +144,13 @@ ORDER BY 1, 2, 3, 4; -- Currently executing and recently executed queries with status, duration, database, etc. SELECT TRIM(status) AS status, TRIM(db_name) AS db, TRIM(user_name) AS "user", TRIM(label) AS query_group, starttime AS start_time, recents.duration, query AS sql FROM stv_recents r LEFT JOIN stv_inflight i ON r.pid = i.pid; -- See the remote host and port of running queries SELECT -
iconara revised this gist
Feb 19, 2016 . 1 changed file with 5 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -144,9 +144,10 @@ ORDER BY 1, 2, 3, 4; -- Currently executing and recently executed queries with status, duration, database, etc. SELECT TRIM(status) AS status, r.starttime AS start_time, duration, db_name AS db, user_name AS "user" r.query AS sql, TRIM(label) AS query_group FROM stv_recents r LEFT JOIN stv_inflight i ON r.pid = i.pid; @@ -155,9 +156,10 @@ SELECT SELECT TRIM(db_name) AS db, TRIM(user_name) AS "user", TRIM(label) AS query_group, starttime AS start_time, recents.duration, query AS sql, remotehost AS remote_host, remoteport AS remote_port FROM stv_recents recents LEFT JOIN stl_connection_log connections ON (recents.pid = connections.pid) -
iconara revised this gist
Feb 19, 2016 . 1 changed file with 14 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -149,4 +149,17 @@ SELECT db_name AS "database", r.query AS sql, TRIM(label) AS query_group FROM stv_recents r LEFT JOIN stv_inflight i ON r.pid = i.pid; -- See the remote host and port of running queries SELECT TRIM(db_name) AS db, TRIM(user_name) AS "user", starttime AS start_time, recents.duration, query, remotehost AS remote_host, remoteport AS remote_port FROM stv_recents recents LEFT JOIN stl_connection_log connections ON (recents.pid = connections.pid) WHERE TRIM(status) = 'Running' AND event = 'initiating session'; -
iconara revised this gist
Feb 9, 2016 . 1 changed file with 14 additions and 13 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -92,16 +92,17 @@ GROUP BY 1, 2 ORDER BY 1 DESC; -- Query duration stats per database, user and query group; including the max, median, 99 percentile, etc. -- Change which duration to use (queue, exec or total) by commenting out the right lines below WITH durations1 AS ( SELECT TRIM("database") AS db, TRIM(u.usename) AS "user", TRIM(label) AS query_group, DATE_TRUNC('day', starttime) AS day, -- total_queue_time/1000000.0 AS duration, -- total_exec_time/1000000.0 AS duration, (total_queue_time + total_exec_time)/1000000.0 AS duration FROM stl_query q, stl_wlm_query w, pg_user u WHERE q.query = w.query AND q.userid = u.usesysid @@ -113,29 +114,29 @@ durations2 AS ( "user", query_group, day, duration, PERCENTILE_CONT(0.50) WITHIN GROUP (ORDER BY duration) OVER (PARTITION BY db, "user", query_group, day) AS median, PERCENTILE_CONT(0.75) WITHIN GROUP (ORDER BY duration) OVER (PARTITION BY db, "user", query_group, day) AS p75, PERCENTILE_CONT(0.90) WITHIN GROUP (ORDER BY duration) OVER (PARTITION BY db, "user", query_group, day) AS p90, PERCENTILE_CONT(0.95) WITHIN GROUP (ORDER BY duration) OVER (PARTITION BY db, "user", query_group, day) AS p95, PERCENTILE_CONT(0.99) WITHIN GROUP (ORDER BY duration) OVER (PARTITION BY db, "user", query_group, day) AS p99, PERCENTILE_CONT(0.999) WITHIN GROUP (ORDER BY duration) OVER (PARTITION BY db, "user", query_group, day) AS p999 FROM durations1 ) SELECT db, "user", query_group, day, MIN(duration) AS min, AVG(duration) AS avg, MAX(median) AS median, MAX(p75) AS p75, MAX(p90) AS p90, MAX(p95) AS p95, MAX(p99) AS p99, MAX(p999) AS p999, MAX(duration) AS max FROM durations2 GROUP BY 1, 2, 3, 4 ORDER BY 1, 2, 3, 4; -
iconara revised this gist
Feb 9, 2016 . 1 changed file with 18 additions and 14 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -99,39 +99,43 @@ durations1 AS ( TRIM(u.usename) AS "user", TRIM(label) AS query_group, DATE_TRUNC('day', starttime) AS day, total_queue_time/1000000.0 AS queue_duration, total_exec_time/1000000.0 AS exec_duration, (total_queue_time + total_exec_time)/1000000.0 AS total_duration FROM stl_query q, stl_wlm_query w, pg_user u WHERE q.query = w.query AND q.userid = u.usesysid AND aborted = 0 ), durations2 AS ( SELECT db, "user", query_group, day, total_duration, PERCENTILE_CONT(0.50) WITHIN GROUP (ORDER BY total_duration) OVER (PARTITION BY db, "user", query_group, day) AS median, PERCENTILE_CONT(0.75) WITHIN GROUP (ORDER BY total_duration) OVER (PARTITION BY db, "user", query_group, day) AS p75, PERCENTILE_CONT(0.90) WITHIN GROUP (ORDER BY total_duration) OVER (PARTITION BY db, "user", query_group, day) AS p90, PERCENTILE_CONT(0.95) WITHIN GROUP (ORDER BY total_duration) OVER (PARTITION BY db, "user", query_group, day) AS p95, PERCENTILE_CONT(0.99) WITHIN GROUP (ORDER BY total_duration) OVER (PARTITION BY db, "user", query_group, day) AS p99, PERCENTILE_CONT(0.999) WITHIN GROUP (ORDER BY total_duration) OVER (PARTITION BY db, "user", query_group, day) AS p999 FROM durations1 ) SELECT db, "user", query_group, day, MIN(total_duration) AS min, AVG(total_duration) AS avg, MAX(median) AS median, MAX(p75) AS p75, MAX(p90) AS p90, MAX(p95) AS p95, MAX(p99) AS p99, MAX(p999) AS p999, MAX(total_duration) AS max FROM durations2 GROUP BY 1, 2, 3, 4 ORDER BY 1, 2, 3, 4; -
iconara revised this gist
Feb 9, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -101,7 +101,7 @@ durations1 AS ( DATE_TRUNC('day', starttime) AS day, DATEDIFF(milliseconds, starttime, endtime)/1000.0 AS duration FROM stl_query q, pg_user u WHERE u.usesysid = q.userid AND querytxt LIKE 'SELECT%' AND "database" != 'dev' ), durations2 AS ( SELECT -
iconara revised this gist
Feb 9, 2016 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -96,7 +96,7 @@ WITH durations1 AS ( SELECT TRIM("database") AS db, TRIM(u.usename) AS "user", TRIM(label) AS query_group, DATE_TRUNC('day', starttime) AS day, DATEDIFF(milliseconds, starttime, endtime)/1000.0 AS duration @@ -106,7 +106,7 @@ durations1 AS ( durations2 AS ( SELECT db, "user", query_group, day, duration, @@ -120,7 +120,7 @@ durations2 AS ( ) SELECT db, "user", query_group, day, MIN(duration) AS min, -
iconara revised this gist
Feb 9, 2016 . 1 changed file with 7 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -91,13 +91,13 @@ FROM stl_ddltext GROUP BY 1, 2 ORDER BY 1 DESC; -- Query duration stats per database, user and query group; including the max, median, 99 percentile, etc. WITH durations1 AS ( SELECT TRIM("database") AS db, TRIM(u.usename) AS user, TRIM(label) AS query_group, DATE_TRUNC('day', starttime) AS day, DATEDIFF(milliseconds, starttime, endtime)/1000.0 AS duration FROM stl_query q, pg_user u @@ -106,8 +106,8 @@ durations1 AS ( durations2 AS ( SELECT db, user, query_group, day, duration, PERCENTILE_CONT(0.50) WITHIN GROUP (ORDER BY DURATION) OVER (PARTITION BY db, day) AS median, @@ -120,8 +120,8 @@ durations2 AS ( ) SELECT db, user, query_group, day, MIN(duration) AS min, AVG(duration) AS avg, -
iconara revised this gist
Feb 9, 2016 . 1 changed file with 11 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -91,19 +91,23 @@ FROM stl_ddltext GROUP BY 1, 2 ORDER BY 1 DESC; -- Query duration stats per database, user and WLM queue; including the max, median, 99 percentile, etc. WITH durations1 AS ( SELECT TRIM("database") AS db, TRIM(u.usename) AS "user", TRIM(label) AS label, DATE_TRUNC('day', starttime) AS day, DATEDIFF(milliseconds, starttime, endtime)/1000.0 AS duration FROM stl_query q, pg_user u WHERE u.usesysid = q.userid and label = 'default' AND querytxt LIKE 'SELECT%' AND "database" != 'dev' ), durations2 AS ( SELECT db, "user", label, day, duration, PERCENTILE_CONT(0.50) WITHIN GROUP (ORDER BY DURATION) OVER (PARTITION BY db, day) AS median, @@ -116,6 +120,8 @@ durations2 AS ( ) SELECT db, "user", label, day, MIN(duration) AS min, AVG(duration) AS avg, @@ -127,8 +133,8 @@ SELECT MAX(p999) AS p999, MAX(duration) AS max FROM durations2 GROUP BY 1, 2, 3, 4 ORDER BY 1, 2, 3, 4; -- Currently executing and recently executed queries with status, duration, database, etc. SELECT -
iconara revised this gist
Jan 14, 2016 . 1 changed file with 11 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -128,4 +128,14 @@ SELECT MAX(duration) AS max FROM durations2 GROUP BY 1, 2 ORDER BY 1, 2 -- Currently executing and recently executed queries with status, duration, database, etc. SELECT TRIM(status) AS status, r.starttime, duration, db_name AS "database", r.query AS sql, TRIM(label) AS query_group FROM stv_recents r LEFT JOIN stv_inflight i ON r.pid = i.pid; -
iconara revised this gist
Dec 21, 2015 . 1 changed file with 40 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -89,4 +89,43 @@ SELECT LISTAGG(text) WITHIN GROUP (ORDER BY sequence) AS sql FROM stl_ddltext GROUP BY 1, 2 ORDER BY 1 DESC; -- Query duration stats including the max, median, 99 percentile, etc. WITH durations1 AS ( SELECT TRIM("database") AS db, DATE_TRUNC('day', starttime) AS day, DATEDIFF(milliseconds, starttime, endtime)/1000.0 AS duration FROM stl_query WHERE label = 'default' AND querytxt LIKE 'SELECT%' AND "database" != 'dev' ), durations2 AS ( SELECT db, day, duration, PERCENTILE_CONT(0.50) WITHIN GROUP (ORDER BY DURATION) OVER (PARTITION BY db, day) AS median, PERCENTILE_CONT(0.75) WITHIN GROUP (ORDER BY DURATION) OVER (PARTITION BY db, day) AS p75, PERCENTILE_CONT(0.90) WITHIN GROUP (ORDER BY DURATION) OVER (PARTITION BY db, day) AS p90, PERCENTILE_CONT(0.95) WITHIN GROUP (ORDER BY DURATION) OVER (PARTITION BY db, day) AS p95, PERCENTILE_CONT(0.99) WITHIN GROUP (ORDER BY DURATION) OVER (PARTITION BY db, day) AS p99, PERCENTILE_CONT(0.999) WITHIN GROUP (ORDER BY DURATION) OVER (PARTITION BY db, day) AS p999 FROM durations1 ) SELECT db, day, MIN(duration) AS min, AVG(duration) AS avg, MAX(median) AS median, MAX(p75) AS p75, MAX(p90) AS p90, MAX(p95) AS p95, MAX(p99) AS p99, MAX(p999) AS p999, MAX(duration) AS max FROM durations2 GROUP BY 1, 2 ORDER BY 1, 2 -
iconara revised this gist
Dec 17, 2015 . 1 changed file with 10 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -80,4 +80,13 @@ FROM stl_query q JOIN query_sql qs ON (q.query = qs.query) WHERE q.query = … ORDER BY starttime; -- Show the most recently executed DDL statements SELECT starttime, xid, LISTAGG(text) WITHIN GROUP (ORDER BY sequence) AS sql FROM stl_ddltext GROUP BY 1, 2 ORDER BY 1 DESC; -
iconara revised this gist
Dec 17, 2015 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -57,6 +57,7 @@ FROM STL_QUERYTEXT WHERE query = …; -- Get the full SQL, plus more query details from a query ID -- filter on xid to see all (including Redshift internal) operations in the transaction WITH query_sql AS ( SELECT query, @@ -71,10 +72,12 @@ SELECT pid, starttime, endtime, DATEDIFF(milliseconds, starttime, endtime)/1000.0 AS duration, TRIM(database) AS database, (CASE aborted WHEN 1 THEN TRUE ELSE FALSE END) AS aborted, sql FROM stl_query q JOIN query_sql qs ON (q.query = qs.query) WHERE q.query = … ORDER BY starttime; -
iconara revised this gist
Dec 17, 2015 . 1 changed file with 24 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -54,4 +54,27 @@ SELECT TIMESTAMP 'epoch' + (millisecond_timestamp/1000 * INTERVAL '1 second') FR -- Get the full SQL from a query ID SELECT LISTAGG(text) WITHIN GROUP (ORDER BY sequence) AS sql FROM STL_QUERYTEXT WHERE query = …; -- Get the full SQL, plus more query details from a query ID WITH query_sql AS ( SELECT query, LISTAGG(text) WITHIN GROUP (ORDER BY sequence) AS sql FROM stl_querytext GROUP BY 1 ) SELECT q.query, userid, xid, pid, starttime, endtime, TRIM(database) AS database, (CASE aborted WHEN 1 THEN TRUE ELSE FALSE END) AS aborted, sql FROM stl_query q JOIN query_sql qs ON (q.query = qs.query) WHERE q.query = …; -
iconara revised this gist
Dec 17, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -53,5 +53,5 @@ SELECT TIMESTAMP 'epoch' + (millisecond_timestamp/1000 * INTERVAL '1 second') FR -- Get the full SQL from a query ID SELECT LISTAGG(text) WITHIN GROUP (ORDER BY sequence) AS sql FROM STL_QUERYTEXT WHERE query = …; -
iconara revised this gist
Dec 17, 2015 . 1 changed file with 6 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -49,4 +49,9 @@ ORDER BY starttime DESC LIMIT 100; -- Convert a millisecond resolution number to a TIMESTAMP SELECT TIMESTAMP 'epoch' + (millisecond_timestamp/1000 * INTERVAL '1 second') FROM …; -- Get the full SQL from a query ID SELECT LISTAGG(text) WITHIN GROUP (ORDER BY sequence) AS sql FROM SVV_QUERY_INFLIGHT WHERE query = …; -
iconara revised this gist
Nov 11, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -49,4 +49,4 @@ ORDER BY starttime DESC LIMIT 100; -- Convert a millisecond resolution number to a TIMESTAMP SELECT TIMESTAMP 'epoch' + (millisecond_timestamp/1000 * INTERVAL '1 second') FROM …; -
iconara revised this gist
Nov 11, 2015 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -46,4 +46,7 @@ SELECT * FROM pg_database; SELECT * FROM stl_load_errors ORDER BY starttime DESC LIMIT 100; -- Convert a millisecond resolution number to a TIMESTAMP SELECT TIMESTAMP 'epoch' + (timestamp/1000 * INTERVAL '1 second') FROM foo; -
iconara revised this gist
Nov 6, 2015 . 1 changed file with 8 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -39,4 +39,11 @@ SELECT * FROM pg_user; SELECT * FROM pg_group; -- List all databases SELECT * FROM pg_database; -- List the 100 last load errors -- see http://docs.aws.amazon.com/redshift/latest/dg/r_STL_LOAD_ERRORS.html SELECT * FROM stl_load_errors ORDER BY starttime DESC LIMIT 100; -
iconara revised this gist
Nov 4, 2015 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -36,4 +36,7 @@ ORDER BY 1, 2; -- List users and groups SELECT * FROM pg_user; SELECT * FROM pg_group; -- List all databases SELECT * FROM pg_database; -
iconara revised this gist
Nov 4, 2015 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -32,4 +32,8 @@ FROM svv_diskusage.col = pg_attribute.attnum-1 AND svv_diskusage.tbl = pg_attribute.attrelid GROUP BY 1, 2 ORDER BY 1, 2; -- List users and groups SELECT * FROM pg_user; SELECT * FROM pg_group;
NewerOlder