postgresql/src
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
..
backend From: Dan McGuirk <mcguirk@indirect.com> 1997-03-28 07:06:53 +00:00
bin '\h create index' shows that multi-column indices are available now. 1997-03-26 03:01:29 +00:00
include From: Dan McGuirk <mcguirk@indirect.com> 1997-03-28 07:06:53 +00:00
interfaces Various patches for shared libraries under i386-solaris by: 1997-03-25 09:21:59 +00:00
man From: Andrew Martin <martin@biochemistry.ucl.ac.uk> 1997-03-15 01:11:54 +00:00
port Various patches for shared libraries under i386-solaris by: 1997-03-25 09:21:59 +00:00
test Date/Time updates from Thomas... 1997-03-14 23:34:16 +00:00
tools/mkldexport End of the make file simplifications. 1996-11-12 11:43:32 +00:00
tutorial Silence compiler warnings, fix error in complex compare function. 1997-01-05 21:20:34 +00:00
utils Remove WIN32 defines. They never worked. 1997-02-14 04:19:07 +00:00
BACKEND_DIRS Small regression and doc patch 1996-12-13 02:39:00 +00:00
build Add ability to change installation directory in build, prior to configure 1997-03-26 06:54:01 +00:00
config.guess Bring back in the autoconf files - work in progress 1997-02-04 08:53:45 +00:00
config.sub Start of a univel port by "Michael P. Snyder" <msnyder@hawkeye.huntersmoon.com> 1997-03-25 07:16:36 +00:00
configure Add checs for float.h 1997-03-25 20:02:42 +00:00
configure.in Add checs for float.h 1997-03-25 20:02:42 +00:00
GNUmakefile.in Make sure anything configure related is removed on a distclean 1997-02-28 18:45:17 +00:00
install-sh Bring back in the autoconf files - work in progress 1997-02-04 08:53:45 +00:00
MAKE_CTAGS Add execute permission. 1996-10-08 04:09:50 +00:00
MAKE_ETAGS Try to fix mode. 1996-11-07 05:15:31 +00:00
MAKE_MKID Renamed file. 1996-10-05 21:16:34 +00:00
Makefile Rename Makefile to GNUmakefile to catch people using other makes. 1996-12-31 07:26:27 +00:00
Makefile.global.in Add ability to change installation directory in build, prior to configure 1997-03-26 06:54:01 +00:00