postgresql/src/backend
Alvaro Herrera 13aa624431 Optimize updating a row that's locked by same xid
Updating or locking a row that was already locked by the same
transaction under the same Xid caused a MultiXact to be created; but
this is unnecessary, because there's no usefulness in being able to
differentiate two locks by the same transaction.  In particular, if a
transaction executed SELECT FOR UPDATE followed by an UPDATE that didn't
modify columns of the key, we would dutifully represent the resulting
combination as a multixact -- even though a single key-update is
sufficient.

Optimize the case so that only the strongest of both locks/updates is
represented in Xmax.  This can save some Xmax's from becoming
MultiXacts, which can be a significant optimization.

This missed optimization opportunity was spotted by Andres Freund while
investigating a bug reported by Oliver Seemann in message
CANCipfpfzoYnOz5jj=UZ70_R=CwDHv36dqWSpwsi27vpm1z5sA@mail.gmail.com
and also directly as a performance regression reported by Dong Ye in
message
d54b8387.000012d8.00000010@YED-DEVD1.vmware.com
Reportedly, this patch fixes the performance regression.

Since the missing optimization was reported as a significant performance
regression from 9.2, backpatch to 9.3.

Andres Freund, tweaked by Álvaro Herrera
2013-12-19 16:53:49 -03:00
..
access Optimize updating a row that's locked by same xid 2013-12-19 16:53:49 -03:00
bootstrap Allow on-detach callbacks for dynamic shared memory segments. 2013-12-18 13:09:09 -05:00
catalog Allow on-detach callbacks for dynamic shared memory segments. 2013-12-18 13:09:09 -05:00
commands Allow on-detach callbacks for dynamic shared memory segments. 2013-12-18 13:09:09 -05:00
executor Support multi-argument UNNEST(), and TABLE() syntax for multiple functions. 2013-11-21 19:37:20 -05:00
foreign Arrange to cache FdwRoutine structs in foreign tables' relcache entries. 2013-03-06 23:48:09 -05:00
lib Use improved vsnprintf calling logic in more places. 2013-10-24 21:43:57 -04:00
libpq Fix incorrect error message reported for non-existent users 2013-12-18 12:16:21 -05:00
main Fix incorrect error message reported for non-existent users 2013-12-18 12:16:21 -05:00
nodes Add ALTER SYSTEM command to edit the server configuration file. 2013-12-18 23:42:44 +09:00
optimizer Fix inherited UPDATE/DELETE with UNION ALL subqueries. 2013-12-14 17:33:53 -05:00
parser Add ALTER SYSTEM command to edit the server configuration file. 2013-12-18 23:42:44 +09:00
po Translation updates 2013-12-02 00:17:07 -05:00
port Remove IRIX port. 2013-10-18 08:14:21 -04:00
postmaster New autovacuum_work_mem parameter 2013-12-12 11:42:39 +00:00
regex Fix regex match failures for backrefs combined with non-greedy quantifiers. 2013-07-18 21:22:37 -04:00
replication Add ALTER SYSTEM command to edit the server configuration file. 2013-12-18 23:42:44 +09:00
rewrite Refine our definition of what constitutes a system relation. 2013-11-28 20:57:20 -05:00
snowball Update copyrights for 2013 2013-01-01 17:15:01 -05:00
storage Allow on-detach callbacks for dynamic shared memory segments. 2013-12-18 13:09:09 -05:00
tcop Add ALTER SYSTEM command to edit the server configuration file. 2013-12-18 23:42:44 +09:00
tsearch pgindent run for release 9.3 2013-05-29 16:58:43 -04:00
utils Allow on-detach callbacks for dynamic shared memory segments. 2013-12-18 13:09:09 -05:00
.gitignore Add gitignore for mingw/cygwin build outputs 2011-06-09 18:11:47 +02:00
Makefile Move relpath() to libpgcommon 2013-02-21 22:46:17 -03:00
common.mk Remove maintainer-check target, fold into normal build 2013-10-10 20:11:56 -04:00
nls.mk Add libpgcommon to backend gettext source files 2013-10-19 13:49:05 -04:00