2ndQuadrant / audit-trigger

Simple, easily customised trigger-based auditing for PostgreSQL (Postgres). See also pgaudit.
Other
659 stars 241 forks source link

Why do comments say the transaction id "May wrap, but unique paired with action_tstamp_tx" #40

Closed jpollard-cs closed 2 years ago

jpollard-cs commented 4 years ago

Hello πŸ‘‹ πŸ˜ƒ

I'm curious why the comments on the transaction_id field indicates that it

"May wrap, but unique paired with action_tstamp_tx".

The PostgreSQL docs (going back even to 9.1) say of txid_current (and related functions):

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. The data type used by these functions, txid_snapshot, stores information about transaction ID visibility at a particular moment in time.

Also would it be worth adding a helpful note to users that they may want to modify / remove the use of clock_timestamp if they don't need it as it could add significant performance overhead to bulk inserts? Curious what the primary use case is here? I could see this perhaps being useful if reading uncommitted data?

Thanks!

tbussmann commented 4 years ago

I'm curious why the comments on the transaction_id field indicates that it

I'd agree - this seems to be a thinko.

Also would it be worth adding a helpful note to users that they may want to modify / remove the use of clock_timestamp if they don't need it as it could add significant performance overhead to bulk inserts?

Here I don't see why the use of clock_timestamp may be a significant performance overhead in particular. At least I don't read that from the linked blog post. The example given there is the inability to use an index when filtering on clock_timestamp due to the volatile nature of the function.

jpollard-cs commented 4 years ago

Oh right I see what you're saying - I misread that one πŸ™ƒ

jpollard-cs commented 4 years ago

Happy to put in a PR to update if we have a high degree of confidence here that this is a thinko