postgresql参数配置杂记

本文探讨了PostgreSQL中关键参数的设置方法,包括shared_buffers、effective_cache_size和checkpoint_segments等,提供了不同内存配置下的推荐值,并解释了这些设置如何影响数据库性能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

shared_buffers
[quote]if you have a system with 1GB or more of RAM, a reasonable starting value for shared_buffers is 1/4 of the memory in your system. If you have less ram you'll have to account more carefully for how much RAM the OS is taking up, closer to 15% is more typical there. [/quote]

[quote]on Windows (and on PostgreSQL versions before 8.1), large values for shared_buffers aren't as effective, and you may find better results keeping it relatively low and using the OS cache more instead. On Windows the useful range is 64MB to 512MB[/quote]

effective_cache_size
[quote]Setting effective_cache_size to 1/2 of total memory would be a normal conservative setting, and 3/4 of memory is a more aggressive but still reasonable amount. HUP is enough ,shared_buffers 一半[/quote]

checkpoint_segments
[quote]doing one every 48MB will be a serious performance bottleneck. 小于3性能慢
Unless you're running on a very small configuration, you'll almost certainly be better setting this to at least 10, which also allows usefully increasing the completion target.至少10
For more write-heavy systems, values from 32 (checkpoint every 512MB) to 256 (every 4GB) are popular nowadays.稍重的写,32 - 256
Normally the large settings (>64/1GB) are only used for bulk loading. 大负载,用64以上[/quote]

fsync关闭会使数据不一致
full_page_writes synchronous_commit只会丢失整个事务,不会不一致
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值