In Postgres 11, according to documentation, txid_current() should return biginteger but I'm getting small integer that doesn't look like is extended by epoch counter. My txid looks like this: 1123

"The internal transaction ID type (xid) is 32 bits wide and wraps
around every 4 billion transactions. However, these functions 
export a 64-bit format that is extended with an “epoch” counter
so it will not wrap around during the life of an installation."


Am I interpreting documentation incorrectly?

  • How do you know 1123 is not a bigint value? Try with: select pg_typeof(txid_current()); – McNets Jun 28 at 13:02
  • The txid supposed to be extended with an epoch counter. I don't see it extended by epoch anywhere. Even if epoch is added to an ID and the sum is displayed as txid I still don't understant how it is extended since txids are serial numbers without regard to a time interval between transactions. – Jimski Jun 28 at 17:22

The internal transaction counter in PostgreSQL is 4 bytes wide, but txid_current() will return a bigint that keeps increasing even after transaction wraparound. Think of it as an “external transaction ID”.


Postgres has an internal 32bit xid counter which is different than the value returned by txid_current().

The txid_current() returns 64bit (bigint) in which the high bits are an epoch increment which happens once per xid wrap around.

So at every wraparound the epoch kicks in and txid_current() keeps incrementing. Thats why at a fresh launch of Postgres the returned txid looks like a regular integer and the epoch element is not apparent.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.