4 ms·
Quibble: the "now()" function doesn't return the time of statement start; it returns the time of transaction start. $ psql -q rosser=# begin; rosser=# se
by rosser 11y ago
Quibble: the "now()" function doesn't return the time of statement start; it returns the time of transaction start.
$ psql -q
rosser=# begin;
rosser=# select now();
now
-------------------------------
2015-09-11 02:28:54.262142-07
(1 row)
rosser=# select now();
now
-------------------------------
2015-09-11 02:28:54.262142-07
(1 row)
- cleansy 11y agoThat's also not completely acurate: postgres=> SELECT now(), now(), clock_timestamp(), clock_timestamp(); now | now | clock_timestamp | clock_timestamp -------------------------------+-------------------------------+-------------------------------+------------------------------ 2015-09-11 09:57:00.414422+00 | 2015-09-11 09:57:00.414422+00 | 2015-09-11 09:57:00.419087+00 | 2015-09-11 09:57:00.41909+00 Now() stays the same for the entire statement as well. clock_timestamp() doesn't.
- fgutmann 11y agoIf you ever manage to have multiple transactions in one statement please email me.
- deleted 11y ago[deleted]
- lsaferite 11y agoThanks for the chuckle. (Yes, I know this adds nothing to the discussion)
- AlterEgo20 11y agoEasy. Just use dblink or foreign table to execute part of the statement inside other transaction. dblink to the same server/db is often used as way to create an "AUTONOMOUS_TRANSACTION"
- simonpantzare 11y agoCame here to mention this. Aside from now()/transaction_timestamp() and clock_timestamp() there's also statement_timestamp() that returns the start time of the current statement.