如何查找 postgresql 表中的观察数

发布于 2024-09-07 03:47:13 字数 238 浏览 1 评论 0原文

我来自 DW/BI 背景,使用 SAS 多年,现在我的任务是找出 postgresql 表中表中存在的记录数量,

即在 SAS 中,我们有元表,其中包含有关表的详细信息、记录数量、列信息等在系统元表中以相同的方式postgresql中是否有可用的元表来动态观察?

我知道我们可以从表中选择 count(*) 但我不想这样做,我想知道 postgresql 中是否有内置元表来获取表中存在的记录?

非常感谢您的帮助。

I am from DW/BI background using SAS for many years now I have task to find out number of records present 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

以可爱出名 2024-09-14 03:47:13

pg_class 系统目录包含有关每个关系(表、索引、视图、序列...)的信息。对于表,这包括表占用的元组(行)数量和磁盘页数的估计。例如:

SELECT reltuples, relpages FROM pg_class WHERE oid = 'table_name'::regclass

请注意,reltuples 是“实数”类型,因此存储大约 6 个有效数字。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文