Skip to content

Instantly share code, notes, and snippets.

@JNajera
Forked from manuelvanrijn/total_rows.sql
Created October 29, 2013 18:18
Show Gist options
  • Save JNajera/7219879 to your computer and use it in GitHub Desktop.
Save JNajera/7219879 to your computer and use it in GitHub Desktop.
SELECT
SUM(pgClass.reltuples) AS totalRowCount
FROM
pg_class pgClass
LEFT JOIN
pg_namespace pgNamespace ON (pgNamespace.oid = pgClass.relnamespace)
WHERE
pgNamespace.nspname NOT IN ('pg_catalog', 'information_schema') AND
pgClass.relkind='r'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment