pgsql: Advance backend's advertised xmin more aggressively.

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Advance backend's advertised xmin more aggressively.
Date: 2015-01-16 23:18:31
Message-ID: E1YCG9v-0003Pv-LQ@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2015-01-16 23:19:13 pgsql: Show sort ordering options in EXPLAIN output.
Previous Message Tom Lane 2015-01-16 18:28:35 pgsql: Improve new caching logic in tbm_add_tuples().