PostgreSQL

PgSQL: View Rows Per Table

Two Methods:

First:

SELECT schemaname,relname,n_live_tup
FROM pg_stat_user_tables
ORDER BY n_live_tup DESC;

 

Second:

SELECT
nspname AS schemaname,relname,reltuples
FROM pg_class C
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
WHERE
nspname NOT IN (‘pg_catalog’, ‘information_schema’) AND
relkind=’r’
ORDER BY reltuples DESC;

Leave a Reply

Your email address will not be published. Required fields are marked *