pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Shadovitz <david@www.shadovitz.com>
To: Aram Kananov <aram@kananov.com>
To: pgsql-performance@postgresql.org <pgsql-performance@postgresql.org>
Subject: Re: Measuring execution time for sql called from PL/pgSQL
Date: Thu, 11 Dec 2003 18:50:31 -0700
Message-ID: <20031212015031.M16173@www.shadovitz.com> (raw)
In-Reply-To: <1071191825.5163.164.camel@localhost.localdomain>
References: <1071191825.5163.164.camel@localhost.localdomain>

> I've tried to measure the duration of sql with printing out
> "localtimestamp"  but for some reason during the same pg/plsql call 
> it returns the same value:

Aram,

From http://www.postgresql.org/docs/current/static/functions-datetime.html:

There is also the function timeofday(), which for historical reasons returns 
a text string rather than a timestamp value: 

SELECT timeofday();
 Result: Sat Feb 17 19:07:32.000126 2001 EST

It is important to know that CURRENT_TIMESTAMP and related functions return 
the start time of the current transaction; their values do not change during 
the transaction. This is considered a feature: the intent is to allow a 
single transaction to have a consistent notion of the "current" time, so that 
multiple modifications within the same transaction bear the same time stamp. 
timeofday() returns the wall-clock time and does advance during transactions. 

-David



view thread (3+ messages)  latest in thread

Message-ID: <20031212015031.M16173@www.shadovitz.com>
Permalink:  ../20031212015031.M16173@www.shadovitz.com/
Also on:    postgresql.org/message-id/20031212015031.M16173@www.shadovitz.com

 · 

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: david@www.shadovitz.com, aram@kananov.com
  Subject: Re: Measuring execution time for sql called from PL/pgSQL
  In-Reply-To: <20031212015031.M16173@www.shadovitz.com>

* 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