diff options
author | Robert Haas <rhaas@postgresql.org> | 2011-10-28 17:08:09 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2011-10-28 17:08:09 -0400 |
commit | 53f1ca59b5875f1d3e95ee709ecaddcbdfdbd175 (patch) | |
tree | 8b99d7bf6dd756a5994846ca6295dd4d15974503 /src/backend/utils/time/tqual.c | |
parent | b6335a3f1b33e5dc52e755956d8648f0813252c4 (diff) | |
download | postgresql-53f1ca59b5875f1d3e95ee709ecaddcbdfdbd175.tar.gz postgresql-53f1ca59b5875f1d3e95ee709ecaddcbdfdbd175.zip |
Allow hint bits to be set sooner for temporary and unlogged tables.
We need not wait until the commit record is durably on disk, because
in the event of a crash the page we're updating with hint bits will
be gone anyway. Per off-list report from Heikki Linnakangas, this
can significantly degrade the performance of unlogged tables; I was
able to show a 2x speedup from this patch on a pgbench run with scale
factor 15. In practice, this will mostly help small, heavily updated
tables, because on larger tables you're unlikely to run into the same
row again before the commit record makes it out to disk.
Diffstat (limited to 'src/backend/utils/time/tqual.c')
-rw-r--r-- | src/backend/utils/time/tqual.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/backend/utils/time/tqual.c b/src/backend/utils/time/tqual.c index d81ee7de062..1c4b74d94b5 100644 --- a/src/backend/utils/time/tqual.c +++ b/src/backend/utils/time/tqual.c @@ -82,10 +82,12 @@ static bool XidInMVCCSnapshot(TransactionId xid, Snapshot snapshot); * Set commit/abort hint bits on a tuple, if appropriate at this time. * * It is only safe to set a transaction-committed hint bit if we know the - * transaction's commit record has been flushed to disk. We cannot change - * the LSN of the page here because we may hold only a share lock on the - * buffer, so we can't use the LSN to interlock this; we have to just refrain - * from setting the hint bit until some future re-examination of the tuple. + * transaction's commit record has been flushed to disk, or if the table is + * temporary or unlogged and will be obliterated by a crash anyway. We + * cannot change the LSN of the page here because we may hold only a share + * lock on the buffer, so we can't use the LSN to interlock this; we have to + * just refrain from setting the hint bit until some future re-examination + * of the tuple. * * We can always set hint bits when marking a transaction aborted. (Some * code in heapam.c relies on that!) @@ -113,7 +115,7 @@ SetHintBits(HeapTupleHeader tuple, Buffer buffer, /* NB: xid must be known committed here! */ XLogRecPtr commitLSN = TransactionIdGetCommitLSN(xid); - if (XLogNeedsFlush(commitLSN)) + if (XLogNeedsFlush(commitLSN) && BufferIsPermanent(buffer)) return; /* not flushed yet, so don't set hint */ } |