mirror of
https://github.com/postgres/postgres.git
synced 2025-09-09 13:09:39 +03:00
Implement lazy XID allocation: transactions that do not modify any database
rows will normally never obtain an XID at all. We already did things this way for subtransactions, but this patch extends the concept to top-level transactions. In applications where there are lots of short read-only transactions, this should improve performance noticeably; not so much from removal of the actual XID-assignments, as from reduction of overhead that's driven by the rate of XID consumption. We add a concept of a "virtual transaction ID" so that active transactions can be uniquely identified even if they don't have a regular XID. This is a much lighter-weight concept: uniqueness of VXIDs is only guaranteed over the short term, and no on-disk record is made about them. Florian Pflug, with some editorialization by Tom.
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/backend/access/transam/clog.c,v 1.43 2007/08/01 22:45:07 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/access/transam/clog.c,v 1.44 2007/09/05 18:10:47 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -423,10 +423,6 @@ CLOGPagePrecedes(int page1, int page2)
|
||||
|
||||
/*
|
||||
* Write a ZEROPAGE xlog record
|
||||
*
|
||||
* Note: xlog record is marked as outside transaction control, since we
|
||||
* want it to be redone whether the invoking transaction commits or not.
|
||||
* (Besides which, this is normally done just before entering a transaction.)
|
||||
*/
|
||||
static void
|
||||
WriteZeroPageXlogRec(int pageno)
|
||||
@@ -437,7 +433,7 @@ WriteZeroPageXlogRec(int pageno)
|
||||
rdata.len = sizeof(int);
|
||||
rdata.buffer = InvalidBuffer;
|
||||
rdata.next = NULL;
|
||||
(void) XLogInsert(RM_CLOG_ID, CLOG_ZEROPAGE | XLOG_NO_TRAN, &rdata);
|
||||
(void) XLogInsert(RM_CLOG_ID, CLOG_ZEROPAGE, &rdata);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -445,9 +441,6 @@ WriteZeroPageXlogRec(int pageno)
|
||||
*
|
||||
* We must flush the xlog record to disk before returning --- see notes
|
||||
* in TruncateCLOG().
|
||||
*
|
||||
* Note: xlog record is marked as outside transaction control, since we
|
||||
* want it to be redone whether the invoking transaction commits or not.
|
||||
*/
|
||||
static void
|
||||
WriteTruncateXlogRec(int pageno)
|
||||
@@ -459,7 +452,7 @@ WriteTruncateXlogRec(int pageno)
|
||||
rdata.len = sizeof(int);
|
||||
rdata.buffer = InvalidBuffer;
|
||||
rdata.next = NULL;
|
||||
recptr = XLogInsert(RM_CLOG_ID, CLOG_TRUNCATE | XLOG_NO_TRAN, &rdata);
|
||||
recptr = XLogInsert(RM_CLOG_ID, CLOG_TRUNCATE, &rdata);
|
||||
XLogFlush(recptr);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user