pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Craig Ringer <craig@postnewspapers.com.au>
To: pgsql-performance@postgresql.org
Subject: Re: Fw: query total time im milliseconds
Date: Mon, 11 Jul 2011 06:54:00 +0800
Message-ID: <4E1A2D88.5040902@postnewspapers.com.au> (raw)
In-Reply-To: <1310322371.24647.YahooMailRC@web38604.mail.mud.yahoo.com>
References: <1310298105.48876.YahooMailRC@web38605.mail.mud.yahoo.com>
	<CAEV0TzCZVv2Ge0t6-hc3rb2H2WJye8GOmo1X1CeFMoYkQvkYhg@mail.gmail.com>
	<1310322371.24647.YahooMailRC@web38604.mail.mud.yahoo.com>

On 11/07/2011 2:26 AM, Radhya sahal wrote:

> long startTime = System.currentTimeMillis();
> //execute query
> long executionTime = System.currentTimeMillis() - startTime;
>
> this executionTime is not an actual time for query ,
> it includes time for access to postgresql server
> using JDBC


The pg_stat_statements contrib module in PostgreSQL 8.4 and above might 
be able to do what you want. See the documentation here:

   http://www.postgresql.org/docs/9.0/static/pgstatstatements.html

I don't think the core PostgreSQL server currently retains information 
about how long the last query executed ran for.  I thought the PL/PgSQL 
"GET DIAGNOSTICS" statement might be able to find out how long the last 
query run within that PL/PgSQL function took, but it can't. So I think 
you're out of luck for now.

PostgreSQL *CAN* log query durations to the server log, it just doesn't 
(AFAIK) offer any way to find out how long the last query took from SQL 
and doesn't keep that information after the statement finishes.

--
Craig Ringer

POST Newspapers
276 Onslow Rd, Shenton Park
Ph: 08 9381 3088     Fax: 08 9388 2258
ABN: 50 008 917 717
http://www.postnewspapers.com.au/



view thread (8+ messages)

Message-ID: <4E1A2D88.5040902@postnewspapers.com.au>
Permalink:  ../4E1A2D88.5040902@postnewspapers.com.au/
Also on:    postgresql.org/message-id/4E1A2D88.5040902@postnewspapers.com.au

 · 

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: craig@postnewspapers.com.au
  Subject: Re: Fw: query total time im milliseconds
  In-Reply-To: <4E1A2D88.5040902@postnewspapers.com.au>

* 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