pg_relation_size ( relation regclass [, fork text ] ) → bigint
Computes the disk space used by one “fork” of the specified relation. (Note that for most purposes it is more convenient to use the higher-level functions pg_total_relation_size or pg_table_size , which sum the sizes of all forks.) With one argument, this returns the size of the main data fork of the relation. The second argument can be provided to specify which fork to examine:
-
main returns the size of the main data fork of the relation.
-
fsm returns the size of the Free Space Map (see Section 68.3) associated with the relation.
-
vm returns the size of the Visibility Map (see Section 68.4) associated with the relation.
-
init returns the size of the initialization fork, if any, associated with the relation,无日志表和索引有(参见https://postgrespro.com/blog/pgsql/5967858,恢复时用到).
|
|
一个表通常具有4个fork,main(第一个,数据本身,包括表和索引), fsm,vm(对所有事务都可见的页面,仅包含冻结元素的页面,查询优化目的,索引没有vm,每个页面2位,第一位表示页面中的所有元素对所有事务可见,用于确认是否可使用Index only scan;第二位,表示页面是否冻结,如果冻结了,anti-wraparound vacuum不需要访问该页面。设置了一定成立,未设置未必不成立,pg_visibility可用来检查实际值),init。
vacuum与否对性能还是有较大的影响,具体可参见postgresql/lightdb vacuum对性能的影响。

参考:
https://habr.com/en/company/postgrespro/blog/469087/
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!
2022-06-23 lightdb异常There is a column named <xxx> in table <xxx>, but it cannot be referenced fromthis part of the query
2022-06-23 oracle到lightdb迁移
2022-06-23 mysql到lightdb迁移