February 2020
Intermediate to advanced
734 pages
38h 13m
English
As the postgres user on a suitable PostgreSQL cluster, follow these steps to find horizontal scalability candidates:
WITH db AS (
SELECT d.datname AS database_name,
d.xact_commit + d.xact_rollback AS transactions,
d.tup_inserted + d.tup_updated
+ d.tup_deleted AS writes,
sum(s.calls) AS queries
FROM pg_stat_database d
LEFT JOIN pg_stat_statements s ON (s.dbid = d.datid)
WHERE d.datname NOT IN (
'template0', 'template1', 'postgres'
)
GROUP BY 1, 2, 3
)
SELECT *
FROM db
WHERE db.transactions > 10000000
OR db.writes > 100000000
OR db.queries > 100000000;
CREATE OR REPLACE VIEW v_shard_candidates ...
Read now
Unlock full access