| From: | Hannu Krosing <hannuk(at)google(dot)com> |
|---|---|
| To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Dilip Kumar <dilipkumarb(at)google(dot)com> |
| Subject: | Patch: VACUUM should ignore (CREATE |RE)INDEX CONCURRENTLY for xmin horizon calculations |
| Date: | 2025-11-24 21:18:26 |
| Message-ID: | CAMT0RQQHmxoY5gKmm9c_pD85kgFAYNXF4VEWpamysF0t_j2t5Q@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
When VACUUM decides which rows are safe to freeze or permanently
remove it currently ignores backends which have PROC_IN_VACUUM or
PROC_IN_LOGICAL_DECODING bits set.
This patch adds PROC_IN_SAFE_IC to this set, so backends running
CREATE INDEX CONCURRENTLY or REINDEX CONCURRENTLY and where the index
is "simple" - i.e. not expression indexes or conditional indexes are
involved - these would be ignored too.
The reasoning behind this is simple:
1) Why this is safe:
a) The vacuum operation can not run on the same table that vacuum is
working on because of locks.
b) The CIC operation only runs on a single table in one transaction,
so it can not touch other tables
2) Why this is useful:
CIC can take significant amount of time, and in case of high-traffic
database with vacuum cleanups blocked a significant amount of dead
rows can accumulate which can have significant impact on certain
workloads. The worst affected are the ones that are considered
anti-patterns anyway, like updatein a single counter row from all DML,
but this can work "well enough" if all the DML transactions are tiny
and and the performance can be maintained between vacuum runs by just
setting the deleted flags in indexes and heap which currentlyis also
blocke.
Future improvements
It would be good to do some more introspection to determine if the CIC
skipping is also safe for specifioc cases of expression and
conditional indexes which are currently excluded from setting the
PROC_IN_SAFE_IC flag.
---
Hannu
| Attachment | Content-Type | Size |
|---|---|---|
| 0001-ignore-CIC-in-VACUUM.patch | application/x-patch | 959 bytes |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Pavel Stehule | 2025-11-24 21:19:10 | Re: proposal: schema variables |
| Previous Message | Tom Lane | 2025-11-24 21:15:10 | Re: Add notification on BEGIN ATOMIC SQL functions using temp relations |