类型: integer
默认: 1024 (8MB)
最低限度: 16 (128kB)
最大: 1073741823 (8589934584kB)
单元: 8kB
上下文: postmaster
重新开始: true

设置数据库服务器将使用的共享内存缓冲区量。默认通常是 128 兆字节(128MB),但是如果你的内核设置不支持(在initdb时决定),那么可以会更少。 这个设置必须至少为 128 千字节。不过为了更好的性能,通常会使用明显高于最小值的设置。 如果指定值时没有单位,则以块为单位,即BLCKSZ字节,通常为8kB.(BLCKSZ 的非默认值改变最小值。) 此参数只能在服务器启动时设置。

如果有一个专用的 1GB 或更多内存的数据库服务器,一个合理的shared_buffers开始值是系统内存的 25%。即使更大的shared_buffers有效,也会造成一些工作负载, 但因为PostgreSQL同样依赖操作系统的高速缓冲区,将shared_buffers设置为超过 40% 的RAM不太可能比一个小点值工作得更好。为了能把对写大量新的或改变的数据的处理分布在一个较长的时间段内,shared_buffers更大的设置通常要求对max_wal_size也做相应增加。

如果系统内存小于 1GB,一个较小的 RAM 百分数是合适的,这样可以为操作系统留下足够的空间。

建议 [EN]

A memory quantity defining PostgreSQL's "dedicated" RAM, which is used for connection control, active operations, and more. However, since PostgreSQL also needs free RAM for file system buffers, sorts and maintenance operations, it is not advisable to set shared_buffers to a majority of RAM. Note that increasing shared_buffers often requires you to increase some system kernel parameters, most notably SHMMAX and SHMALL. See Operating System Environment: Managing Kernel Resources in the PostgreSQL documentation for more details. Also note that shared_buffers over 2GB is only supported on 64-bit systems.

条评论