Re: Measuring execution time for sql called from PL/pgSQL - Mailing list pgsql-performance

From David Shadovitz
Subject Re: Measuring execution time for sql called from PL/pgSQL
Date
Msg-id 20031212015031.M16173@www.shadovitz.com
Whole thread Raw
In response to Measuring execution time for sql called from PL/pgSQL  (Aram Kananov <aram@kananov.com>)
List pgsql-performance
> 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

pgsql-performance by date:

Previous
From: "Chadwick, Russell"
Date:
Subject: Excessive rows/tuples seriously degrading query performance
Next
From: "Nick Fankhauser - Doxpop"
Date:
Subject: Nested loop question