More aggressive vacuuming of temporary tables
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-hackers@lists.postgresql.org
Date: 2020-08-28T15:46:49Z
Lists: pgsql-hackers
Attachments
- 0001-vacuum-temp-tables-aggressively.patch (text/x-diff) patch 0001
- 0002-gin-vacuum-coverage.patch (text/x-diff) patch 0002
It strikes me that when we are vacuuming a temporary table (which necessarily will be one of our own session), we don't really need to care what the global xmin horizon is. If we're not inside a user transaction block, then there are no tuples in the table that could be in-doubt anymore. Neither are there any snapshots in our session that could see any dead tuples. Nor do we give a fig what other sessions might think of those tuples. So we could just set the xmin cutoff as aggressively as possible, which is to say equal to the nextXid counter. While vacuuming a temp table is perhaps not something people do very often, I think when they do do it they would like us to clean out all the dead tuples not just some. Hence I propose 0001 attached. 80% of it is just API additions to allow passing down the isTopLevel flag so that we can do the right thing in the CLUSTER case; the important change is in vacuum_set_xid_limits. (For ease of review, I didn't reindent the existing code in vacuum_set_xid_limits, but that would be something to do before commit.) The reason I got interested in this is that yesterday while fooling with bug #16595, I was annoyed about our poor code test coverage in access/gin/. The 0002 patch attached brings coverage for ginvacuum.c up from 59% to 93%; but as things stand, a long delay has to be inserted between the DELETE and VACUUM steps, else the VACUUM won't remove the dead tuples because of concurrent transactions, and we get no coverage improvement. Since the table in question is a temp table, that seems pretty silly. Thoughts? Am I missing something important here? regards, tom lane
Commits
-
Centralize horizon determination for temp tables, fixing bug due to skew.
- 94bc27b57680 14.0 landed
-
Improve test coverage of ginvacuum.c.
- 4c51a2d1e4b7 14.0 landed
-
Set cutoff xmin more aggressively when vacuuming a temporary table.
- a7212be8b9e0 14.0 landed