postgresql/src/include/access
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
..
attnum.h remove: 1996-10-31 09:51:30 +00:00
funcindex.h More cleanups of the include files 1996-08-28 01:59:28 +00:00
genam.h index_insert has now HeapRelation as last param (for 1997-01-10 09:36:34 +00:00
gist.h index_insert has now HeapRelation as last param (for 1997-01-10 09:36:34 +00:00
gistscan.h All external function definitions now have prototypes that are checked. 1996-11-10 03:06:38 +00:00
giststrat.h All external function definitions now have prototypes that are checked. 1996-11-10 03:06:38 +00:00
hash.h index_insert has now HeapRelation as last param (for 1997-01-10 09:36:34 +00:00
heapam.h All external function definitions now have prototypes that are checked. 1996-11-10 03:06:38 +00:00
heaptuple.h And another... 1996-11-05 07:18:05 +00:00
hio.h these ones have their dependencies cleaned up 1996-11-05 10:37:16 +00:00
htup.h -Wall based cleanup of include files, based from acl.h, and everything 1996-11-04 07:18:46 +00:00
ibit.h Another 1996-11-05 07:24:03 +00:00
iqual.h these ones have their dependencies cleaned up 1996-11-05 10:37:16 +00:00
istrat.h these ones have their dependencies cleaned up 1996-11-05 10:37:16 +00:00
itup.h Another one bits the dust... 1996-11-05 07:20:09 +00:00
nbtree.h New func _bt_checkkeys() added to let caller know number of keys 1997-03-24 08:04:51 +00:00
printtup.h another gone 1996-11-06 08:52:04 +00:00
relscan.h another pass through. 1996-11-04 08:53:07 +00:00
rtree.h index_insert has now HeapRelation as last param (for 1997-01-10 09:36:34 +00:00
rtscan.h Moved from backend/access to include/access 1996-08-27 21:50:29 +00:00
rtstrat.h Moved from backend/access to include/access 1996-08-27 21:50:29 +00:00
sdir.h remove: 1996-10-31 09:51:30 +00:00
skey.h Another series started from utils/builtins.h 1996-11-04 07:46:06 +00:00
strat.h Another series started from utils/builtins.h 1996-11-04 07:46:06 +00:00
transam.h TransactionIdIsInProgress moved to shmem.c 1996-11-27 07:32:10 +00:00
tupdesc.h Another series started from utils/builtins.h 1996-11-04 07:46:06 +00:00
tupmacs.h Moved from backend/access to include/access 1996-08-27 21:50:29 +00:00
valid.h From: Dan McGuirk <mcguirk@indirect.com> 1997-03-28 07:06:53 +00:00
xact.h All external function definitions now have prototypes that are checked. 1996-11-10 03:06:38 +00:00