From: Tom Lane <tgl@sss.pgh.pa.us>
To: Holger Jakobs <holger@jakobs.com>
Cc: pgsql-admin <pgsql-admin@postgresql.org>
Subject: Re: now() and statement_timestamp()
Date: Thu, 27 May 2021 12:43:56 -0400
Message-ID: <1785725.1622133836@sss.pgh.pa.us> (raw)
In-Reply-To: <536812b3-8040-371d-506d-266bcf10ec2f@jakobs.com>
References: <536812b3-8040-371d-506d-266bcf10ec2f@jakobs.com>
Holger Jakobs <holger@jakobs.com> writes:
> So in psql now() and statement_timestamp() are identical when not in a
> transaction, while in the others the two values vary a little bit,
> roughly 100 microseconds.
> How come the same statements aren't behaving identical. I'm using a
> current PostgreSQL server on a Linux machine.
I'd try turning on log_statement = all to see what's actually
happening. What seems somewhat likely is that the non-psql
cases are wrapping the command you gave in BEGIN/COMMIT,
or something along that line.
[ thinks for a bit ] It could also be down to the wire protocol
used. psql is just sending a simple Query message, but the
other two might well be sending Parse/Bind/Execute. IIRC the
transaction must be started by Bind, but we may consider
the statement timestamp to be the start of processing Execute.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-admin@postgresql.org
Cc: tgl@sss.pgh.pa.us, holger@jakobs.com
Subject: Re: now() and statement_timestamp()
In-Reply-To: <1785725.1622133836@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox