On psql I can type the following:
BEGIN;
what do I type to get the current id of the newly created transaction?
I am trying to put together a demo that explains how vaccum and MVVC work in postgres. For example select xmin, xmax, * from test;
shows the xmin and xmax of each row from the point of view of the current transaction.
I understand the basic theory of it but want to put together an interactive exercise such that I can have two psql consoles open and then have a set of step by step instructions that show mvcc and vaccum work.
How do I get the current postgres transaction id?
Postgres has added txid_current_if_assigned()
in version 10.
"System Information Functions", "Transaction IDs and Snapshots".
You can get the transaction id from:
txid_current()
You can additionally get the in-progress transactions in the snaption it's seeing from:
txid_snapshot_xip(txid_current_snapshot())
A few more functions are detailed in the manual:
http://www.postgresql.org/docs/current/static/functions-info.html#FUNCTIONS-TXID-SNAPSHOT
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With