diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c index 92afc32..b0b0a8d 100644 --- a/src/backend/utils/time/snapmgr.c +++ b/src/backend/utils/time/snapmgr.c @@ -979,6 +979,14 @@ SnapshotResetXmin(void) if (pairingheap_is_empty(&RegisteredSnapshots)) { + /* + * PgXact->xmin access bottlenecks on larger servers, so we choose + * to skip this if we have reason to believe that the xmin would not + * be long-lived such as when idle_in_transaction_timeout is set. + */ + if (IdleInTransactionSessionTimeout > 0) + return; + MyPgXact->xmin = InvalidTransactionId; return; } diff --git a/src/include/utils/snapmgr.h b/src/include/utils/snapmgr.h index 2618cc4..828a257 100644 --- a/src/include/utils/snapmgr.h +++ b/src/include/utils/snapmgr.h @@ -47,7 +47,7 @@ /* GUC variables */ extern PGDLLIMPORT int old_snapshot_threshold; - +extern int IdleInTransactionSessionTimeout; /* copied from proc.h for convenience */ extern Size SnapMgrShmemSize(void); extern void SnapMgrInit(void);