如何 change/set Postgres 中的块大小?有配置文件吗?

How to change/set the block size in Postgres? Is there any file to make the configuration?

我正在寻找 postgres 中的 BLOCKSIZE 配置。我想知道有没有办法 change/set 这个值?

对于不同的数据块大小,您必须在配置后重新编译 PostgreSQL

./configure --with-blocksize=<size in kB>

但我不建议这样做,因为我从未听说过有人使用它,而且您有可能通过这种方式发现有趣的 PostgreSQL 错误。

这不是运行时配置。

https://www.postgresql.org/docs/current/storage-page-layout.html

Every table and index is stored as an array of pages of a fixed size (usually 8 kB, although a different page size can be selected when compiling the server).

您需要从源代码编译 postgres,并在配置步骤中传递大小为 kB 的附加标志:

./configure --with-blocksize=BLOCKSIZE --with-wal-blocksize=BLOCKSIZE

默认BLOCKSIZE为8kB,最大值:32kB

安装成功后,您可以通过执行以下命令确认当前块大小:

SELECT current_setting('block_size');