From: | Holger Jakobs <holger(at)jakobs(dot)com> |
---|---|
To: | pgsql-admin <pgsql-admin(at)postgresql(dot)org> |
Subject: | now() and statement_timestamp() |
Date: | 2021-05-27 16:26:42 |
Message-ID: | 536812b3-8040-371d-506d-266bcf10ec2f@jakobs.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
According to the documentation. now() should yield the timestamp of the
current transaction, while statement_timestamp() should yield the
timestamp of the current statement.
In case of Autocommit, both should be identical, in case of a running
transaction, they should be different.
Funny enough, psql and executing the same statement from within an
application yield different results. I tried a Tcl script and DBeaver.
Statement: |SELECT now(), statement_timestamp();|
psql: |2021-05-07 13:31:10.135851+02 | 2021-05-07 13:31:10.135851+02|
DBeaver: |2021-05-07 13:31:00.633784+02|2021-05-07 13:31:00.633913+02|
Tcl script: |{now {2021-05-07 13:24:54.659837+02} statement_timestamp
{2021-05-07 13:24:54.65985+02}}|
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.
--
Holger Jakobs, Bergisch Gladbach, Tel. +49-178-9759012
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2021-05-27 16:36:51 | Re: Mat view sometimes taking 10x the time to refresh concurrently |
Previous Message | Wells Oliver | 2021-05-27 16:15:12 | Mat view sometimes taking 10x the time to refresh concurrently |