Skip to content

Instantly share code, notes, and snippets.

View mezis's full-sized avatar

Julien Letessier mezis

View GitHub Profile
--
-- PostgreSQL memory usage
-- Requires the pg_buffercache extension
--
SELECT
n.nspname, c.relkind, c.relname,
COUNT(1) AS buffers,
-- (100 * COUNT(1) * 8192.0 / pg_table_size(c.oid))::INT AS pct_cached,
RPAD(LPAD('', (COUNT(1) * 8192e1 / pg_table_size(c.oid))::INT, '█'), 10, '░') AS pct_cached,