Re: now() and statement_timestamp()

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Holger Jakobs <holger(at)jakobs(dot)com>
Cc: pgsql-admin <pgsql-admin(at)postgresql(dot)org>
Subject: Re: now() and statement_timestamp()
Date: 2021-05-27 16:43:56
Message-ID: 1785725.1622133836@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Holger Jakobs <holger(at)jakobs(dot)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

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Vijaykumar Jain 2021-05-27 17:05:50 Re: Mat view sometimes taking 10x the time to refresh concurrently
Previous Message Wells Oliver 2021-05-27 16:38:13 Re: Mat view sometimes taking 10x the time to refresh concurrently