HEY:
Work in progress.
Performance
Monitoring
Checking table sizes details and pretty printing it.
SELECT
relname AS table_name,
pg_size_pretty(pg_total_relation_size(relid)) AS total,
pg_size_pretty(pg_relation_size(relid)) AS internal,
pg_size_pretty(pg_table_size(relid) - pg_relation_size(relid)) AS external,
pg_size_pretty(pg_indexes_size(relid)) AS indexes
FROM pg_catalog.pg_statio_user_tables
ORDER BY pg_total_relation_size(relid) DESC;
Best practices
If you are looking for a COUNT, rather than running the query to spot the count of rows at the bottom of the screen, use a subquery that counts the rows for you.
select count(*) from
(
select
userid
from userschema.usertable
where market = 'UK'
and payingcustomer = 1
) as derivedtable;
#application#design#sql