

<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
From: Zhilong Liu &lt;[email-masked]&gt;</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
Date: Thu, 28 May 2026 17:52:41 +0800</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
Subject: [PATCH] doc: explain database-wide impact of old xmin on VACUUM</d=
iv>
<div dir=3D"ltr" style=3D"font-family: Aptos, Arial, Helvetica, sans-serif;=
 font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
Add a note to the &quot;Recovering Disk Space&quot; section explaining that=
</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
VACUUM uses the oldest xmin across backends in the current database</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
to decide which tuples are dead, so a long-running transaction on any</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
table can prevent space reclamation for rows newer than that</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
transaction in any table of the same database. Rows older than the</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
oldest active transaction can still be reclaimed normally. Also</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
mention that stale replication slots and prepared transactions have</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
the same effect.</div>
<div dir=3D"ltr" style=3D"font-family: Aptos, Arial, Helvetica, sans-serif;=
 font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
For shared system catalogs, backends in all databases are considered.</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
---</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
Source verification: the database-wide (not cluster-wide) behavior</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
is implemented in ComputeXidHorizons() in procarray.c, which only</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
includes backends where proc-&gt;databaseId =3D=3D MyDatabaseId for the</di=
v>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
data_oldest_nonremovable horizon.</div>
<div dir=3D"ltr" style=3D"font-family: Aptos, Arial, Helvetica, sans-serif;=
 font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
&nbsp;doc/src/sgml/maintenance.sgml | 18 ++++++++++++++++++</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
&nbsp;1 file changed, 18 insertions(+)</div>
<div dir=3D"ltr" style=3D"font-family: Aptos, Arial, Helvetica, sans-serif;=
 font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
diff --git a/doc/src/sgml/maintenance.sgml b/doc/src/sgml/maintenance.sgml<=
/div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
index 4a21bdb..5963ba1 100644</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
--- a/doc/src/sgml/maintenance.sgml</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
+++ b/doc/src/sgml/maintenance.sgml</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
@@ -165,6 +165,24 @@</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
&nbsp; &nbsp; &nbsp;space requirements. This is done by running &lt;command=
&gt;VACUUM&lt;/command&gt;.</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
&nbsp; &nbsp; &lt;/para&gt;</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
&nbsp;</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
+ &nbsp; &lt;note&gt;</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
+ &nbsp; &nbsp;&lt;para&gt;</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
+ &nbsp; &nbsp; To decide which row versions can be removed,</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
+ &nbsp; &nbsp; &lt;command&gt;VACUUM&lt;/command&gt; considers the oldest =
active transaction</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
+ &nbsp; &nbsp; ID (&lt;firstterm&gt;xmin&lt;/firstterm&gt;) across backend=
s in the current</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
+ &nbsp; &nbsp; database. Because of this, a long-running transaction on on=
e table</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
+ &nbsp; &nbsp; can prevent &lt;command&gt;VACUUM&lt;/command&gt; from recl=
aiming space</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
+ &nbsp; &nbsp; occupied by rows that are newer than that transaction in</d=
iv>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
+ &nbsp; &nbsp; &lt;emphasis&gt;any&lt;/emphasis&gt; table in the same data=
base. For rows</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
+ &nbsp; &nbsp; older than the oldest active transaction,</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
+ &nbsp; &nbsp; &lt;command&gt;VACUUM&lt;/command&gt; can still reclaim the=
m normally. Stale</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
+ &nbsp; &nbsp; replication slots and abandoned prepared transactions have =
the</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
+ &nbsp; &nbsp; same effect, since they also hold old xmin values that bloc=
k</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
+ &nbsp; &nbsp; cleanup. Note that for shared system catalogs, backends in =
all</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
+ &nbsp; &nbsp; databases are considered. For troubleshooting, see</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
+ &nbsp; &nbsp; &lt;xref linkend=3D&quot;vacuum-for-wraparound&quot;/&gt;.<=
/div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
+ &nbsp; &nbsp;&lt;/para&gt;</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
+ &nbsp; &lt;/note&gt;</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
+</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
&nbsp; &nbsp; &lt;para&gt;</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
&nbsp; &nbsp; &nbsp;The standard form of &lt;command&gt;VACUUM&lt;/command&=
gt; removes dead row</div>
<div style=3D"font-family: Aptos, Arial, Helvetica, sans-serif; font-size: =
12pt; color: rgb(0, 0, 0);">
&nbsp; &nbsp; &nbsp;versions in tables and indexes and marks the space avai=
lable for</div>
<div dir=3D"ltr" style=3D"font-family: Aptos, Arial, Helvetica, sans-serif;=
 font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div dir=3D"ltr" style=3D"font-family: Aptos, Arial, Helvetica, sans-serif;=
 font-size: 12pt; color: rgb(0, 0, 0);">
--</div>
<div id=3D"ms-outlook-mobile-signature">
<div style=3D"font-family: system-ui, -apple-system, BlinkMacSystemFont, &q=
uot;Segoe UI&quot;, Roboto, Oxygen-Sans, Ubuntu, Cantarell, &quot;Helvetica=
 Neue&quot;, Arial, sans-serif; font-size: 14px; color: rgb(43, 46, 47);">
<span style=3D"background-color: rgb(255, 255, 255);">Best regards,&nbsp;</=
span></div>
<div style=3D"font-family: system-ui, -apple-system, BlinkMacSystemFont, &q=
uot;Segoe UI&quot;, Roboto, Oxygen-Sans, Ubuntu, Cantarell, &quot;Helvetica=
 Neue&quot;, Arial, sans-serif; font-size: 14px; color: rgb(43, 46, 47);">
<span style=3D"background-color: rgb(255, 255, 255);">Zhilong Liu</span></d=
iv>
</div>
</body>
</html>

--_000_OS3PR01MB8553C5907830DE25A8A4986ED9152OS3PR01MB8553jpnp_--

--_004_OS3PR01MB8553C5907830DE25A8A4986ED9152OS3PR01MB8553jpnp_
Content-Type: application/octet-stream;
	name="0001-doc-explain-database-wide-impact-of-old-xmin-on-VACU.patch"
Content-Description: 
 0001-doc-explain-database-wide-impact-of-old-xmin-on-VACU.patch
Content-Disposition: attachment;
	filename="0001-doc-explain-database-wide-impact-of-old-xmin-on-VACU.patch";
	size=2513; creation-date="Mon, 01 Jun 2026 03:50:38 GMT";
	modification-date="Mon, 01 Jun 2026 03:50:38 GMT"
Content-Transfer-Encoding: base64

--_004_OS3PR01MB8553C5907830DE25A8A4986ED9152OS3PR01MB8553jpnp_--