Skip to content

Instantly share code, notes, and snippets.

@erik-megarad
Created March 28, 2013 18:28
Show Gist options
  • Save erik-megarad/5265641 to your computer and use it in GitHub Desktop.
Save erik-megarad/5265641 to your computer and use it in GitHub Desktop.
TIL: Postgres freezes now() to the start-time of the transaction while inside a transaction.
psql (9.1.3)
Type "help" for help.
dev=# select now();
now
-------------------------------
2013-03-28 14:27:28.820854-04
(1 row)
dev=# select now();
now
-------------------------------
2013-03-28 14:27:29.610072-04
(1 row)
dev=# begin;
BEGIN
dev=# select now();
now
-------------------------------
2013-03-28 14:27:31.129983-04
(1 row)
dev=# select now();
now
-------------------------------
2013-03-28 14:27:31.129983-04
(1 row)
dev=# select now();
now
-------------------------------
2013-03-28 14:27:31.129983-04
(1 row)
dev=# commit;
COMMIT
dev=# select now();
now
-------------------------------
2013-03-28 14:27:41.538059-04
(1 row)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment