为什么在PostgreSQL的表空间中需要TABLESPACE_VERSION_DIRECTORY?

huangapple go评论47阅读模式
英文:

why do we need a TABLESPACE_VERSION_DIRECTORY in PostgreSQL's tablespace?

问题

我找到了位于像pg_tblspc/16384/PG_11_201809051/13888/16385这样的目录下的文件,并发现它们来自TABLESPACE_VERSION_DIRECTORY宏。

但是,我不明白为什么我们需要这个级别的目录。我们不能只使用pg_tblspc/16384/13888/16385吗?有什么好处?如果不使用它会发生什么?它与表空间的符号链接有关吗?

英文:

I found the files in pg_tblspc under directories like pg_tblspc/16384/PG_11_201809051/13888/16385
, and I found they comes from the TABLESPACE_VERSION_DIRECTORY macro.

However, I don't understand why we need this level of directory. Can't we just use pg_tblspc/16384/13888/16385? What is the benefit? What will happen if we don't use it? Does it have any relation to the symbol link of tablespace?

答案1

得分: 0

TABLESPACE_VERSION_DIRECTORY 的目的是为了避免意外使用错误版本的 PostgreSQL 数据文件。在主数据目录中,PG_VERSION 文件已经实现了这个目的。TABLESPACE_VERSION_DIRECTORY 显著体现其作用的一个明显场景是在使用 pg_upgrade 进行升级时:由于表空间目录位置保持不变,不同版本的文件仅通过不同的 TABLESPACE_VERSION_DIRECTORY 区分。

英文:

The purpose of TABLESPACE_VERSION_DIRECTORY is to avoid accidentally using data files with a wrong version of PostgreSQL. In the main data directory, that purpose is served by the PG_VERSION file. One very obvious place where the TABLESPACE_VERSION_DIRECTORY shows its power is during an upgrade with pg_upgrade: since the tablespace directory location stays the same, the files from the different versions are only distinguished by the different TABLESPACE_VERSION_DIRECTORY.

huangapple
  • 本文由 发表于 2023年3月23日 11:55:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/75819132.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定