On Sat, Oct 5, 2024 at 5:03 PM Tom Lane <tgl@xxxxxxxxxxxxx> wrote:
As I mentioned upthread, we currently promise that xact_start matches the query_start of the transaction's first statement. (I'm not sure
how well that's documented, but the code goes out of its way to make it so, so somebody thought it was important.)
I'm not convinced this is terribly useful in practice, but it is good to know.
I think if we wanted to do something here, it'd make more sense to keep xact_start as it stands and introduce a new variable
snapshot_timestamp or something like that.
I agree; I've been thinking about something like this, as it is too hard to try to shoehorn the information into the existing fields. Will throw this onto my "possible patch idea" pile.
Then maybe we could have some guarantees about what you get when comparing other sessions'
xact_start to your own snapshot_timestamp. But I'm not convinced we can really guarantee anything without reading the snapshot_timestamp within the snapshot-collecting critical section, and I'm not for that.
Fair enough, but even a not-guaranteed 100% accurate value might be better than the current situation, which is no (user) visibility at all about the (MVCC) visibility. Heck, even a boolean "snapshot acquired" would be an improvement (which becomes a subset of the info returned by a timestamp via null/notnull).
Cheers,
Greg