- Mastering PostgreSQL 9.6
- Hans Jurgen Schonig
- 239字
- 2021-07-09 19:57:14
Making use of snapshot too old
VACUUM is doing a good job and it will reclaim free space as needed. But when can VACUUM actually clean out rows and turn them into free space? The rule is this: if a row cannot be seen by anybody anymore, it can be reclaimed. In reality this means that everything that is no longer seen even by the oldest transaction can be considered to be really dead.
This also implies that really long transactions can postpone cleanup for quite some time. The logical consequence is table bloat. Tables will grow beyond proportion and performance will tend to go downhill.
Fortunately PostgreSQL 9.6 has a nice feature that allows the administrator to intelligently limit the duration of a transaction. Oracle administrators will be familiar with the snapshot too old error; since PostgreSQL 9.6, this error message is also available. But it is more of a feature than an unintended side-effect of bad configuration (which it actually is in Oracle).
To limit the lifetime of snapshots, you can make use of a setting in postgresql.conf:
old_snapshot_threshold = -1
# 1min-60d; -1 disables; 0 is immediate
If this variable is set, transactions will fail after a certain amount of time. Note that this setting is on an instance level and it cannot be set inside a session. By limiting the size of a transaction, the risk of insanely long transactions will decrease drastically.
- 計(jì)算機(jī)應(yīng)用
- Introduction to DevOps with Kubernetes
- 深度學(xué)習(xí)中的圖像分類與對(duì)抗技術(shù)
- 計(jì)算機(jī)網(wǎng)絡(luò)技術(shù)實(shí)訓(xùn)
- Arduino &樂高創(chuàng)意機(jī)器人制作教程
- 運(yùn)動(dòng)控制器與交流伺服系統(tǒng)的調(diào)試和應(yīng)用
- 觸控顯示技術(shù)
- 具比例時(shí)滯遞歸神經(jīng)網(wǎng)絡(luò)的穩(wěn)定性及其仿真與應(yīng)用
- Hands-On Deep Learning with Go
- 渲染王3ds Max三維特效動(dòng)畫技術(shù)
- 網(wǎng)頁設(shè)計(jì)與制作
- Win 7二十一
- 基于Quartus Ⅱ的數(shù)字系統(tǒng)Verilog HDL設(shè)計(jì)實(shí)例詳解
- ARM嵌入式系統(tǒng)開發(fā)完全入門與主流實(shí)踐
- 這樣用Word!