Advance backend's advertised xmin more aggressively.
Currently, a backend will reset it's PGXACT->xmin value when it doesn't
have any registered snapshots left. That covered the common case that a
transaction in read committed mode runs several queries, one after each
other, as there would be no snapshots active between those queries.
However, if you hold cursors across each of the query, we didn't get a
chance to reset xmin.
To make that better, keep all the registered snapshots in a pairing heap,
ordered by xmin so that it's always quick to find the snapshot with the
smallest xmin. That allows us to advance PGXACT->xmin whenever the oldest
snapshot is deregistered, even if there are others still active.
Per discussion originally started by Jeff Davis back in 2009 and more
recently by Robert Haas.
Branch
------
master
Details
-------
http://git.postgresql.org/pg/commitdiff/94028691609f8e148bd4ce72c46163f018832a5b
Modified Files
--------------
src/backend/utils/time/snapmgr.c | 109 ++++++++++++++++++++++++++------------
src/include/lib/pairingheap.h | 19 +++++++
src/include/utils/snapshot.h | 5 +-
3 files changed, 99 insertions(+), 34 deletions(-)