Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 9FBC3633D36 for ; Tue, 25 May 2010 02:15:18 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 25208-05 for ; Tue, 25 May 2010 05:15:10 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from imail.internode.com.au (exchht01-ext.internode.com.au [203.26.95.185]) by mail.postgresql.org (Postfix) with ESMTP id E31C963416B for ; Tue, 25 May 2010 02:15:09 -0300 (ADT) Received: from EXCHMAIL.staff.internode.com.au ([169.254.1.229]) by exchht01.staff.internode.com.au ([fe80::193f:3ff6:d38f:74dc%12]) with mapi; Tue, 25 May 2010 14:45:06 +0930 From: Samuel Stearns To: Tom Lane CC: "pgsql-admin@postgresql.org" Date: Tue, 25 May 2010 14:45:05 +0930 Subject: Re: transaction_timestamp() Thread-Topic: [ADMIN] transaction_timestamp() Thread-Index: Acr7wzEIkABYtAfXTGGEOMXKfVP9cwABgZzg Message-ID: <68B59BEDCD36854AADBDF17E91B2937A01A57CCD01@EXCHMAIL.staff.internode.com.au> References: <68B59BEDCD36854AADBDF17E91B2937A01A57CCCB9@EXCHMAIL.staff.internode.com.au> <17418.1274761902@sss.pgh.pa.us> In-Reply-To: <17418.1274761902@sss.pgh.pa.us> Accept-Language: en-US, en-AU Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US, en-AU Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201005/229 X-Sequence-Number: 34702 Thanks, Tom. I read it again. I got into trouble using now() before. Transaction_times= tamp() is really what I need, I think. I have a table that is updated multiple times/second. My archiving command operation: BEGIN; INSERT INTO blah_archive (id, user) SELECT id, user FROM blah where date < = (now() - '30 days'::interval); DELETE FROM blah where date < (now() - '30 days'::interval); END; The now() on the INSERT will be a different time than the now() on the DELE= TE resulting in more rows deleted than were inserted. Whereas transaction_timestamp() takes care of the problem because both INSE= RT and DELETE operations work off of the one timestamp that the transaction= started. Sam -----Original Message----- From: Tom Lane [mailto:tgl@sss.pgh.pa.us]=20 Sent: Tuesday, 25 May 2010 2:02 PM To: Samuel Stearns Cc: pgsql-admin@postgresql.org Subject: Re: [ADMIN] transaction_timestamp()=20 Samuel Stearns writes: > I have an archiving script running in an 8.3 environment using transactio= n_timestamp() for the INSERT and DELETE operations. I want to run the same= thing in an 8.1 environment but transaction_timestamp() does not exist in = 8.1. now() will not work because of the time that elapses between the INSE= RT and DELETE operations (I will end up losing some data). Does anyone hav= e any suggestions, please? Um ... transaction_timestamp() is exactly the same thing as now(). Perhaps you need to go re-read http://www.postgresql.org/docs/8.3/static/functions-datetime.html#FUNCTIONS= -DATETIME-CURRENT regards, tom lane