The list of all the queries

Base tables with plenty of data

Query goal: Find base tables that have 1000 rows or more.
Notes about the query: 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.
Query type: General (Overview of some aspect of the database.)
Query license: MIT License
Data source: system catalog only
SQL query: Click on query to copy it

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 where the query belongs to

Category nameCategory description
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.

The list of all the queries