Is now() atomic?

From: Michael Lush <mjlush(at)ebi(dot)ac(dot)uk>
To: pgsql-novice(at)postgresql(dot)org
Subject: Is now() atomic?
Date: 2007-12-13 16:32:57
Message-ID: Pine.LNX.4.64.0712131614180.9633@pigeon.ebi.ac.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


I'm writing a reporting script (on postgres 8.1) that logs some table
stats along with the time, I'd like to write something like this:-

SELECT now(), foo, COUNT(*) FROM table GROUP BY foo;

now | foo | count
--------------------------------+-------+-------
13/12/2007 16:04:49.044687 GMT | A | 21499
13/12/2007 16:04:49.044687 GMT | B | 2517
13/12/2007 16:04:49.044687 GMT | C | 245
.
.
13/12/2007 16:04:49.044687 GMT | ZZZ | 23016

Does now() record the time that the SELECT statement was executed
or the time that the row is printed out?

ie is it possible for the clock to tick during the SELECT resulting in:-

now | foo | count
--------------------------------+-------+-------
13/12/2007 16:04:49.044687 GMT | A | 21499
.
.
13/12/2007 16:04:49.044688 GMT | ZZZ | 23016

--
Michael

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Michael John Lush PhD Tel:44-1223 492626
Bioinformatician
HUGO Gene Nomenclature Committee Email: hgnc(at)genenames(dot)org
European Bioinformatics Institute
Hinxton, Cambridge
URL: http://www.genenames.org
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2007-12-13 16:37:30 Re: Is now() atomic?
Previous Message johnf 2007-12-13 15:12:26 Re: remote user