1
+ txid - export transaction IDs to user level
2
+ ===========================================
1
3
2
- txid - export transaction id's to user level
3
- ============================================
4
-
5
- The goal is to make PostgreSQL internal transaction ID and snapshot
4
+ The goal is to make PostgreSQL's internal transaction ID and snapshot
6
5
data usable externally. This allows very efficient queue
7
6
implementation done inside database.
8
7
@@ -32,7 +31,7 @@ txid_snapshot_xmax( snap ) returns int8
32
31
txid_snapshot_xip( snap ) setof int8
33
32
34
33
List of in-progress TXID's in snapshot, that are invisible.
35
- Values are between xmin and xmax.
34
+ Values are between xmin (inclusive) and xmax (exclusive) .
36
35
37
36
txid_visible_in_snapshot(id, snap) returns bool
38
37
@@ -73,8 +72,8 @@ fetching possible txids below snap1.xmax explicitly:
73
72
AND NOT txid_visible_in_snapshot(ev_txid, :snap1)
74
73
AND txid_visible_in_snapshot(ev_txid, :snap2);
75
74
76
- Note that although the above queries work, the PostgreSQL fails to
77
- plan them correctly . For actual usage the values for txid_snapshot_xmin,
75
+ Note that although the above queries work, PostgreSQL fails to
76
+ plan them efficiently . For actual usage the values for txid_snapshot_xmin,
78
77
txid_snapshot_xmax and txid_snapshot_xip should be filled in directly,
79
78
only then will they use index.
80
79
@@ -92,20 +91,16 @@ To see example code for that it's best to see pgq.batch_event_sql() function in
92
91
Dumping and restoring data containing TXIDs.
93
92
--------------------------------------------
94
93
95
- [towrite: reason for epoch increase]
96
-
97
- You can look at current epoch with query:
98
-
99
- SELECT txid_current() >> 32 as epoch;
94
+ When reloading TXID data you will typically want to be sure that the current
95
+ XID counter is beyond the reloaded data. The easiest way to do this is to
96
+ increase the XID epoch to beyond the largest one in the input data.
100
97
101
- So new epoch should be :
98
+ You can look at current epoch with queries such as :
102
99
103
- SELECT (txid_current( ) >> 32) + 1 as newepoch ;
100
+ SELECT MAX(txid ) >> 32 as epoch FROM ... ;
104
101
105
102
Epoch can be changed with pg_resetxlog command:
106
103
107
104
pg_resetxlog -e NEWEPOCH DATADIR
108
105
109
106
Database needs to be shut down for that moment.
110
-
111
-
0 commit comments