postgresql/src/backend/storage
Marc G. Fournier 159f8c63ad From: Dan McGuirk <mcguirk@indirect.com>
Reply-To: hackers@hub.org, Dan McGuirk <mcguirk@indirect.com>
To: hackers@hub.org
Subject: [HACKERS] tmin writeback optimization

I was doing some profiling of the backend, and noticed that during a certain
benchmark I was running somewhere between 30% and 75% of the backend's CPU
time was being spent in calls to TransactionIdDidCommit() from
HeapTupleSatisfiesNow() or HeapTupleSatisfiesItself() to determine that
changed rows' transactions had in fact been committed even though the rows'
tmin values had not yet been set.

When a query looks at a given row, it needs to figure out whether the
transaction that changed the row has been committed and hence it should pay
attention to the row, or whether on the other hand the transaction is still
in progress or has been aborted and hence the row should be ignored.  If
a tmin value is set, it is known definitively that the row's transaction
has been committed.  However, if tmin is not set, the transaction
referred to in xmin must be looked up in pg_log, and this is what the
backend was spending a lot of time doing during my benchmark.

So, implementing a method suggested by Vadim, I created the following
patch that, the first time a query finds a committed row whose tmin value
is not set, sets it, and marks the buffer where the row is stored as
dirty.  (It works for tmax, too.)  This doesn't result in the boost in
real time performance I was hoping for, however it does decrease backend
CPU usage by up to two-thirds in certain situations, so it could be
rather beneficial in high-concurrency settings.
1997-03-28 07:06:53 +00:00
..
buffer From: Dan McGuirk <mcguirk@indirect.com> 1997-03-28 07:06:53 +00:00
file Make the error message output by AllocateFile() if failes to 1997-02-20 22:54:18 +00:00
ipc From: Dan McGuirk <mcguirk@indirect.com> 1997-03-12 21:13:19 +00:00
large_object Add include files needed for stat(). 1997-01-18 16:14:04 +00:00
lmgr From: Massimo Dal Zotto <dz@cs.unitn.it> 1997-03-15 01:23:58 +00:00
page From: Dan McGuirk <mcguirk@indirect.com> 1997-03-12 21:13:19 +00:00
smgr Remove WIN32 defines. They never worked. 1997-02-14 04:19:07 +00:00
Makefile Recognize dependencies more reliably. 1996-11-10 03:13:59 +00:00