changeset 2330:03d20db65d79

List indexes/constraints.
author Oleksandr Gavenko <gavenkoa@gmail.com>
date Thu, 03 Jan 2019 19:36:18 +0200
parents 738316fb865f
children 32dd4ce8e9b2
files postgres.rst
diffstat 1 files changed, 21 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/postgres.rst	Thu Jan 03 09:39:56 2019 +0200
+++ b/postgres.rst	Thu Jan 03 19:36:18 2019 +0200
@@ -83,6 +83,12 @@
 
    ALTER USER me WITH PASSWORD 'PassWord';
 
+Monitor connections
+===================
+::
+
+   select * from pg_stat_activity;
+
 List databases, schemas and tables
 ==================================
 
@@ -180,6 +186,21 @@
     t.relname,
     i.relname;
 
+List index usage::
+
+  SELECT * FROM pg_stat_all_indexes;
+  SELECT * FROM pg_stat_all_tables;
+  SELECT * FROM pg_stat_user_indexes;
+  SELECT * FROM pg_stat_user_tables;
+
+List constraints::
+
+  SELECT * FROM pg_constraint;
+  SELECT * FROM pg_constraint WHERE conrelid = (SELECT oid FROM pg_class WHERE relname LIKE 'tblName');
+
+https://www.postgresql.org/docs/current/catalog-pg-constraint.html
+  pg_constraint.
+
 List functions::
 
   \df