Last active
December 11, 2019 09:12
-
-
Save mz026/a1a8678c6f78c197049c251405c95aba to your computer and use it in GitHub Desktop.
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 characters
| -- list row counts | |
| SELECT schemaname,relname,n_live_tup | |
| FROM pg_stat_user_tables | |
| ORDER BY n_live_tup DESC; | |
| -- see vacuum records | |
| SELECT | |
| schemaname, relname, | |
| last_vacuum, last_autovacuum, | |
| vacuum_count, autovacuum_count, | |
| last_analyze, last_autoanalyze | |
| FROM pg_stat_user_tables | |
| order by autovacuum_count desc limit 10 | |
| -- see disc usage by tables: | |
| SELECT nspname || '.' || relname AS "relation", | |
| pg_size_pretty(pg_total_relation_size(C.oid)) AS "total_size" | |
| FROM pg_class C | |
| LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace) | |
| WHERE nspname NOT IN ('pg_catalog', 'information_schema') | |
| AND C.relkind <> 'i' | |
| AND nspname !~ '^pg_toast' | |
| ORDER BY pg_total_relation_size(C.oid) DESC | |
| LIMIT 10; | |
| -- list processes | |
| SELECT * from pg_stat_activity ; | |
| -- kill process | |
| SELECT pg_terminate_backend(23509) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment