postgresql/src/backend/access
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
..
common Add a new reloption, user_catalog_table. 2013-12-10 19:17:34 -05:00
gin Mark variables 'static' where possible. Move GinFuzzySearchLimit to ginget.c 2013-12-16 11:41:17 +02:00
gist Don't include unused space in LOG_NEWPAGE records. 2013-12-04 00:10:47 +02:00
hash Consistently use unsigned arithmetic for alignment calculations. 2013-10-20 21:04:52 -04:00
heap Optimize updating a row that's locked by same xid 2013-12-19 16:53:49 -03:00
index Use InvalidSnapshot, now SnapshotNow, as the default snapshot. 2013-07-23 10:58:32 -04:00
nbtree Don't include unused space in LOG_NEWPAGE records. 2013-12-04 00:10:47 +02:00
rmgrdesc Rework tuple freezing protocol 2013-12-16 11:29:50 -03:00
spgist Don't include unused space in LOG_NEWPAGE records. 2013-12-04 00:10:47 +02:00
transam Don't ignore tuple locks propagated by our updates 2013-12-18 13:45:51 -03:00
Makefile Split out rmgr rm_desc functions into their own files 2012-11-28 13:01:15 -03:00