You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
selectc.relnamespace::regnamespace as schema_name,
c.relnameas table_name,
i.indexrelid::regclass as index_name,
i.indisprimaryas is_pk,
i.indisuniqueas is_unique
from pg_index i
join pg_class c onc.oid=i.indrelidwherec.relname='TABLE_NAME'
List all column types across the schema
SELECTn.nspnameAS schema_name,
t.typnameAS type_name,
t.typtypeAS type_type,
t.typcategoryAS type_category
FROM pg_type t
JOIN pg_namespace n ONt.typnamespace=n.oidWHEREn.nspname NOT IN ('pg_catalog', 'information_schema')
ANDt.typtypeIN ('e', 'c'); -- 'e' for ENUM, 'c' for composite types
List history of sequential & index scans across all tables
SELECT
relname AS table_name,
seq_scan,
last_seq_scan,
idx_scan,
last_idx_scan,
seq_scan + idx_scan AS total_accesses
FROM pg_stat_all_tables
WHERE schemaname ='public'ORDER BY total_accesses DESC;