now() and statement_timestamp()

Поиск
Список
Период
Сортировка
От Holger Jakobs
Тема now() and statement_timestamp()
Дата
Msg-id 536812b3-8040-371d-506d-266bcf10ec2f@jakobs.com
обсуждение исходный текст
Ответы Re: now() and statement_timestamp()  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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
Вложения

В списке pgsql-admin по дате отправления:

Предыдущее
От: Wells Oliver
Дата:
Сообщение: Mat view sometimes taking 10x the time to refresh concurrently
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Mat view sometimes taking 10x the time to refresh concurrently