From: | Bruce Momjian <bruce(at)momjian(dot)us> |
---|---|
To: | PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org> |
Subject: | Improvement of procArray.xmin for VACUUM |
Date: | 2007-03-23 21:02:41 |
Message-ID: | 200703232102.l2NL2fW13924@momjian.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-patches |
VACUUM treats dead tuple with an xmax less than all procArray.xmin's as
invisible with space ready to be reused.
Right now, we set procArray.xmin at transaction start to the required
SERIALIZABLE value. We currently don't update procArray.xmin when we
know we are in a READ COMMITTED transaction, even though we already call
GetSnapshotData().
This means that if a transaction completes that was active when our
transaction started, we don't update our procArray.xmin during the next
multi-statement transaction command to indicate that we don't care about
the completed transaction anymore.
I have been thinking we could improve how quickly VACUUM can expire rows
if we update procArray.xmin more frequently for non-SERIALIZABLE
transactions.
The attached patch updates procArray.xmin in this manner. Here is an
example of how the patch improves dead row reuse:
Session #:
1 2 3
CREATE TABLE test(x int);
INSERT INTO test VALUES (1);
BEGIN;
DELETE FROM test;
BEGIN;
SELECT 1;
COMMIT;
VACUUM VERBOSE test;
(row not reused)
SELECT 1;
(At this point #2 doesn't see
the test row anymore. Patch
updates procArray.xmin.)
VACUUM VERBOSE test;
(row reused with patch)
COMMIT;
VACUUM VERBOSE test;
(normal row reuse)
What the patch does is to recompute procArray.xmin during the second
SELECT, which is then used by the next VACUUM.
The patch has debug code that prints the procArray.xmin assignments. I
am not sure if I have all the boolean calls to GetTransactionSnapshot()
correct. The set_procArray_xmin parameter should be true only when we
are sure we aren't going to be resetting the session back to an earlier
snapshot.
The major affect of the patch is to set the minimum procArray.xmin to be
the earliest in-process transaction, rather than the earliest in-process
transaction at transaction start.
--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://www.enterprisedb.com
+ If your life is a hard drive, Christ can be your backup. +
Attachment | Content-Type | Size |
---|---|---|
/pgpatches/xid | text/x-diff | 17.6 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2007-03-23 21:13:14 | Re: Improvement of procArray.xmin for VACUUM |
Previous Message | Magnus Hagander | 2007-03-23 19:18:43 | Re: seg regression failures |