官术网_书友最值得收藏!

  • 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.

主站蜘蛛池模板: 普定县| 锦屏县| 巴青县| 望都县| 嘉善县| 荥阳市| 综艺| 吕梁市| 鹿邑县| 宜川县| 威宁| 新巴尔虎右旗| 阳山县| 潼关县| 北川| 米脂县| 瓮安县| 杂多县| 桂东县| 南靖县| 大洼县| 南木林县| 宣汉县| 南汇区| 遵义市| 石城县| 科技| 福泉市| 海安县| 梁平县| 淮安市| 嘉鱼县| 松桃| 重庆市| 通辽市| 休宁县| 大足县| 阿克苏市| 望奎县| 青田县| 溆浦县|