英文:
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
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论