Last active
August 29, 2015 14:07
-
-
Save rafaelbernard/090a0ec9b219fa660092 to your computer and use it in GitHub Desktop.
Tabelas com maior quantidade de registros em cache - PostgreSQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT d.datname, c.relname | |
, pg_size_pretty(count(*) * 8192) as buffered | |
, round(100.0 * count(*) / ( SELECT setting FROM pg_settings WHERE name='shared_buffers')::integer,1) AS buffers_percent | |
, round(100.0 * count(*) * 8192 / pg_relation_size(c.oid),1) AS percent_of_relation | |
FROM pg_class c | |
INNER JOIN pg_buffercache b ON b.relfilenode = c.relfilenode | |
INNER JOIN pg_database d ON (b.reldatabase = d.oid) | |
WHERE pg_relation_size(c.oid) > 0 | |
GROUP BY c.oid, d.datname, c.relname | |
ORDER BY 4 DESC | |
LIMIT 10; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment