pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Karl O. Pinc <kop@meme.com>
To: Michael Fuhr <mike@fuhr.org>
Cc: pgsql-performance@postgresql.org, Michael Glaesemann <grzm@myrealbox.com>
Subject: Re: Performance analysis of plpgsql code
Date: Tue, 28 Jun 2005 03:03:06 +0000
Message-ID: <1119927786l.11411l.3l@mofo> (raw)
In-Reply-To: <20050628013419.GA17407@winnie.fuhr.org>
References: <1119915045l.4428l.5l@mofo>
	<20050627233303.GA17069@winnie.fuhr.org>
	<1119923648l.11411l.0l@mofo>
	<20050628013419.GA17407@winnie.fuhr.org>


On 06/27/2005 08:34:19 PM, Michael Fuhr wrote:
> On Tue, Jun 28, 2005 at 01:54:08AM +0000, Karl O. Pinc wrote:
> > On 06/27/2005 06:33:03 PM, Michael Fuhr wrote:
> >
> > >See timeofday().
> >
> > That only gives you the time at the start of the transaction,
> > so you get no indication of how long anything in the
> > transaction takes.
> 
> Did you read the documentation or try it?  Perhaps you're thinking
> of now(), current_timestamp, and friends, which don't advance during
> a transaction; but as the documentation states, "timeofday() returns
> the wall-clock time and does advance during transactions."

Very sorry.  I did not read through the complete documentation.

> I just ran tests on versions of PostgreSQL going back to 7.2.8 and
> in all of them timeofday() advanced during a transaction.

For all your work a documentation patch is appended that
I think is easier to read and might avoid this problem
in the future.  If you don't read all the way through the
current cvs version then you might think, as I did,
that timeofday() is a CURRENT_TIMESTAMP related function.

Sorry, but 3 lines wrap in the patch
in my email client.  :(


Karl <kop@meme.com>
Free Software:  "You don't pay back, you pay forward."
                  -- Robert A. Heinlein


inline patch 1: func.sgml.new (+0/-1 lines) download inline-1.patch--- func.sgml 2005-06-26 17:05:35.000000000 -0500 +++ func.sgml.new 2005-06-27 21:51:05.301097896 -0500 @@ -5787,15 +5787,6 @@ </para> <para> - There is also the function <function>timeofday()</function>, which
for historical - reasons returns a <type>text</type> string rather than a <type>timestamp</type> value: -<screen> -SELECT timeofday(); -<lineannotation>Result: </lineannotation><computeroutput>Sat Feb 17 19:07:32.000126 2001 EST</computeroutput> -</screen> - </para> - - <para> It is important to know that <function>CURRENT_TIMESTAMP</function> and related functions return the start time of the current transaction; their values do not @@ -5803,8 +5794,7 @@ the intent is to allow a single transaction to have a consistent notion of the <quote>current</quote> time, so that multiple modifications within the same transaction bear the same - time stamp. <function>timeofday()</function> - returns the wall-clock time and does advance during transactions. + time stamp. </para> <note> @@ -5815,6 +5805,18 @@ </note> <para> + There is also the function <function>timeofday()</function> which + returns the wall-clock time and advances during transactions. For + historical reasons <function>timeofday()</function> returns a + <type>text</type> string rather than a <type>timestamp</type> + value: +<screen> +SELECT timeofday(); +<lineannotation>Result: </lineannotation><computeroutput>Sat Feb 17 19:07:32.000126 2001 EST</computeroutput> +</screen> + </para> + + <para> All the date/time data types also accept the special literal value <literal>now</literal> to specify the current date and time. Thus, the following three all return the same result:

view thread (8+ messages)  latest in thread

Message-ID: <1119927786l.11411l.3l@mofo>
Permalink:  ../1119927786l.11411l.3l@mofo/
Also on:    postgresql.org/message-id/1119927786l.11411l.3l@mofo

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: kop@meme.com, mike@fuhr.org, grzm@myrealbox.com
  Subject: Re: Performance analysis of plpgsql code
  In-Reply-To: <1119927786l.11411l.3l@mofo>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox