如何检查在 PostgreSQL 中存储表需要多少页/块?
假设我们有一个表 PEOPLE
。如何检查将其存储在 PostgreSQL 中需要多少页/块?
Let's suppose we have a table PEOPLE
. How can I check how many pages/blocks are required for storing it in PostgreSQL?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从系统目录中获取当前使用的实际块数
pg_class
:这只是主要关系。而且这个计数可能有些过时了。不包括 TOAST、辅助关系或索引。但它包含任何数量的膨胀,可以使用 VACUUM FULL 或类似工具来消除。更多:
使用
oid::regclass
的表述可以防止与search_path
发生任何混淆。如果该表不可见(search_path
中的第一个表),则输出是架构限定的。Get the actual number of blocks currently used from the system catalog
pg_class
:That's only the main relation. And the count may be somewhat outdated. Not including TOAST, auxiliary relations or indexes. But it includes any amount of bloat, that might be removed with
VACUUM FULL
or similar tools. More:The formulation with
oid::regclass
defends against any confusion with thesearch_path
. If the table is not visible (first one in thesearch_path
), then the output is schema-qualified.