How to find PostgreSQL table size and number of rows with single query

In this article, we will see how to find PostgreSQL table size and number of rows with single query. We can the table size and number of rows by querying against the table pg_stat_user_tables.

Query to find PostgreSQL table size and number of rows
Following query will return the PostgreSQL table size and number of rows of that table.

select pg_relation_size(relid) as tablesize,schemaname, n_live_tup from pg_stat_user_tables where relname='table_name';

Example to find PostgreSQL table size and number of rows
Continue reading How to find PostgreSQL table size and number of rows with single query