From 76cd368939d27afbeebfd544b5fc3059c2de5d57 Mon Sep 17 00:00:00 2001 From: Xiong Ding Date: Thu, 5 Dec 2024 17:21:13 -0800 Subject: [PATCH] TIL --- _posts/2023-12-10-tech-diary.md | 6 ++++++ _posts/2024-12-04-postgres-vacuum.md | 20 ++++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/_posts/2023-12-10-tech-diary.md b/_posts/2023-12-10-tech-diary.md index 2235590..804c987 100644 --- a/_posts/2023-12-10-tech-diary.md +++ b/_posts/2023-12-10-tech-diary.md @@ -7,6 +7,12 @@ tags: [diary] Some random thoughts or learnings. +## 2024-12-05 Thu + +I always came cross real models. For example today +. +Stay focused and consistently! + ## 2024-10-06 Sun I came across this repo when I dig into diff --git a/_posts/2024-12-04-postgres-vacuum.md b/_posts/2024-12-04-postgres-vacuum.md index e47d62e..3d95ba2 100644 --- a/_posts/2024-12-04-postgres-vacuum.md +++ b/_posts/2024-12-04-postgres-vacuum.md @@ -13,7 +13,6 @@ The purpose of vacuum: 3. Prevent transaction id wraparound failure - how to find the max and min XID in postgres - - how is vacuum affected by XID? - how dd dashboard show low row count after failover - how does it set FrozenTransactionId - how MVCC prevents vacuum, and only subset of tables or all tables? @@ -22,9 +21,7 @@ How does vacuum compare XID? See [code](https://github.com/postgres/postgres/blob/a3e6c6f929912f928fa405909d17bcbf0c1b03ee/src/backend/access/transam/transam.c#L280) Wrapp around happens -## Autovacuum - -### When will autovacuum run? +## When will autovacuum run? Autovacuum is controlled by two parameters @@ -97,6 +94,21 @@ VACUUM You see that it skips 1 page due to buffer pins. +## Freezing + +[MVCC in PostgreSQL — 8. Freezing](https://postgrespro.com/blog/pgsql/5967948) +from postgrespro is the best article talking about freezing I can find online. +It creates a live experiment that I can follow. The important parameters that +control the freezing are below: + +- vacuum_freeze_table_age: the age of the transaction for which vacuuming + ignores the visibility map and looks through all the table pages in order to + do freezing +- vacuum_freeze_min_age: the minimum age of the xmin transaction for which a + tuple can be frozen +- autovacuum_freeze_max_age: forced autovacuuming is launched if + pg_class.relfrozenxid is older than this. + ### Logs `log_autovacuum_min_duration` controls the threshold of long-running autovacuum