How to find number of observations in postgresql tables
I am from DW/BI background using SAS for many years now I have task to find out number of records p开发者_开发知识库resent in tables on the fly for postgresql tables
i.e. In SAS we have meta tables which has details about tables and no of records, column info etc in system meta tables in a same manner is there any meta table available in postgresql to get no of observation on the fly?
I know we can do select count(*) from table but I don't want to do that, I want to know is there any built in meta tables in postgresql to get no of records present in table?
Highly appreciated your help.
The pg_class
system catalogue contains information about each relation (table, index, view, sequence...). For tables, this includes an estimate of the number of tuples (rows) and disk pages taken up by the table. e.g.:
SELECT reltuples, relpages FROM pg_class WHERE oid = 'table_name'::regclass
Note that reltuples is of "real" type and so stores about 6 significant figures.
精彩评论