How do you find the row count for all your tables in Postgres?

Started by Nithya Somanabout 12 years ago2 messagesgeneral
Jump to latest
#1Nithya Soman
nithya@quintetsolutions.com

Hi

How can we find the total row count for all db tables in psql version
7.4.3 ??

The query which worked fine in psql 9.2 version is :
SELECT schemaname,relname,n_live_tup FROM pg_stat_user_tables ORDER BY
n_live_tup DESC.

But same query throws error as 'ERROR: column "n_live_tup" does not exist'
in psql 7.4.30. Could you please provide a valid query to get row count for
all db tables in psql 7.4.3 ?

#2Michael Paquier
michael@paquier.xyz
In reply to: Nithya Soman (#1)
Re: How do you find the row count for all your tables in Postgres?

On Mon, Apr 7, 2014 at 6:46 PM, Nithya Soman
<nithya@quintetsolutions.com> wrote:

How can we find the total row count for all db tables in psql version 7.4.3
??

Are you aware that 7.4 is EOL for 5 years? 7.4.3 is missing as well at
least 4 years of bug fixes in its stable branch.

The query which worked fine in psql 9.2 version is :
SELECT schemaname,relname,n_live_tup FROM pg_stat_user_tables ORDER BY
n_live_tup DESC.
But same query throws error as 'ERROR: column "n_live_tup" does not exist'
in psql 7.4.30. Could you please provide a valid query to get row count for
all db tables in psql 7.4.3 ?

The documentation of 7.4 does not mention explicitely what are the
columns of this view, but connecting to a 7.4 server and issuing "¥d
pg_stat_user_tables" would help and you might be able to get an
equivalent of what you are trying to do.
--
Michael

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general