Fork

描述关系物理存储类型的概念

在PostgreSQL的数据目录中,每个关系的数据都存储在所谓的fork

  • 主fork(无后缀)
  • 空闲空间映射(后缀:fsm
  • 可见性映射(后缀:vm
  • 初始化fork(后缀:init

包含实际数据(可能分布在多个文件中)的主fork始终存在。

源代码

src/include/common/relpath.h:

/*
 * Stuff for fork names.
 *
 * The physical storage of a relation consists of one or more forks.
 * The main fork is always created, but in addition to that there can be
 * additional forks for storing various metadata. ForkNumber is used when
 * we need to refer to a specific fork in a relation.
 */
typedef enum ForkNumber
{
        InvalidForkNumber = -1,
        MAIN_FORKNUM = 0,
        FSM_FORKNUM,
        VISIBILITYMAP_FORKNUM,
        INIT_FORKNUM
...
} ForkNumber;

src/common/relpath.c:

/*
 * Lookup table of fork name by fork number.
 *
 * If you add a new entry, remember to update the errhint in
 * forkname_to_number() below, and update the SGML documentation for
 * pg_relation_size().
 */
const char *const forkNames[] = {
	"main",						/* MAIN_FORKNUM */
	"fsm",						/* FSM_FORKNUM */
	"vm",						/* VISIBILITYMAP_FORKNUM */
	"init"						/* INIT_FORKNUM */
};

示例

具有可见性和空闲空间映射fork的关系

-rw-------  1 postgres  postgres  36249600 21 Dec 15:59 16384
-rw-------  1 postgres  postgres     32768 21 Dec 15:59 16384_fsm
-rw-------  1 postgres  postgres      8192 21 Dec 15:59 16384_vm

分类

PostgreSQL内部存储

参见

initialization_fork

反馈

提交任何关于“Fork”的评论、建议或更正 此处