Re: Measuring execution time for sql called from PL/pgSQL

From: "David Shadovitz" <david(at)www(dot)shadovitz(dot)com>
To: Aram Kananov <aram(at)kananov(dot)com>, "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Measuring execution time for sql called from PL/pgSQL
Date: 2003-12-12 01:50:31
Message-ID: 20031212015031.M16173@www.shadovitz.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Alfranio Tavares Correia Junior 2003-12-12 02:35:16 Re: Performance problems with a higher number of clients
Previous Message Aram Kananov 2003-12-12 01:17:06 Measuring execution time for sql called from PL/pgSQL