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
-- report size information for all tables-- Finding the size of your biggest relationsSELECT nspname ||'.'|| relname AS"relation",
pg_size_pretty(pg_relation_size(C.oid)) AS"size"FROM pg_class C
LEFT JOIN pg_namespace N ON (N.oid=C.relnamespace)
WHERE nspname NOT IN ('pg_catalog', 'information_schema')
-- ORDER BY relation asc, size ascORDER BY pg_relation_size(C.oid) DESCLIMIT150;
Get the amount of space used by all databases
SELECT pg_size_pretty(sum(pg_database_size(oid))::BIGINT) FROM pg_database;
Activity connection
SELECT*FROM pg_stat_activity
wherepg_stat_activity.usenamelike'smuapp'order by state, application_name;
find the sessions that are blocking another session.
-- find the sessions that are blocking another session.select pid,
usename,
pg_blocking_pids(pid) as blocked_by,
query as blocked_query
from pg_stat_activity
where cardinality(pg_blocking_pids(pid)) >0;
replica commands
select*from pg_stat_replication;
SELECT slot_name, slot_type, active FROM pg_replication_slots;
connect w/ ssl?
SELECT datname,usename, ssl, client_addr
FROM pg_stat_ssl
JOIN pg_stat_activity
ONpg_stat_ssl.pid=pg_stat_activity.pid;
reload postgresql conf
SELECT pg_reload_conf();
change user search path
ALTER ROLE smudba IN DATABASE smartu
SET search_path TO smu, extensions, "$user";
show postgresql settings
SELECT*FROM pg_settings;
SELECT*FROM pg_settings WHERE name ='%param%';