Goal Find base tables that have 1000 rows or more.
Notes The query does not count the number of actual rows but relies on the result of statistics collection process (see the ANALYZE statement). The side effect of running the test is that the statistics of the entire database will be refreshed.
Type General (Overview of some aspect of the database.)
License MIT License
Data Source system catalog only
SQL Query
ANALYZE;
SELECT n.nspname AS schema_name, c.relname AS table_name, c.reltuples
FROM pg_catalog.pg_class c
INNER JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
INNER JOIN pg_catalog.pg_authid u ON u.oid = c.relowner
WHERE c.relkind IN ('r') 
AND (n.nspname = 'public' OR u.rolname <> 'postgres') 
AND reltuples>=1000
ORDER BY reltuples DESC, n.nspname, c.relname;

Categories

This query is classified under the following categories:

NameDescription
AssessmentQueries of this category could be used specifically in the learning environment to assess as to whether student projects have filled certain criteria.
Data at the database logical levelQueries of this category provide information about data in base tables.