Обсуждение: query total time im milliseconds
Dear all ,
could any one help me?
when i use pgadmin to exceute a query it shows the total time for query ..
such as
(select * form table_name.........)query total time is for example 100 ms
i want to know the command that can retentive the query total time in millisecond
if i connect with postgresql from java using JDBC
i need the query total time necessaryto use it in my project
i don't want run explian just query
thank's
On Sun, Jul 10, 2011 at 4:41 AM, Radhya sahal <rad_cs_2006@yahoo.com> wrote:
Dear all ,could any one help me?when i use pgadmin to exceute a query it shows the total time for query ..such as(select * form table_name.........)query total time is for example 100 msi want to know the command that can retentive the query total time in millisecondif i connect with postgresql from java using JDBCi need the query total time necessaryto use it in my projecti don't want run explian just querythank's
long startTime = System.currentTimeMillis();
//execute query
long executionTime = System.currentTimeMillis() - startTime;
----- Forwarded Message ----
From: Radhya sahal <rad_cs_2006@yahoo.com>
To: Samuel Gendler <sgendler@ideasculptor.com>
Sent: Sun, July 10, 2011 11:25:46 AM
Subject: Re: [PERFORM] query total time im milliseconds
this executionTime is not an actual time for query ,
From: Samuel Gendler <sgendler@ideasculptor.com>
To: Radhya sahal <rad_cs_2006@yahoo.com>
Cc: pgsql-performance group <pgsql-performance@postgresql.org>
Sent: Sun, July 10, 2011 10:51:52 AM
Subject: Re: [PERFORM] query total time im milliseconds
From: Radhya sahal <rad_cs_2006@yahoo.com>
To: Samuel Gendler <sgendler@ideasculptor.com>
Sent: Sun, July 10, 2011 11:25:46 AM
Subject: Re: [PERFORM] query total time im milliseconds
Thank's
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
From: Samuel Gendler <sgendler@ideasculptor.com>
To: Radhya sahal <rad_cs_2006@yahoo.com>
Cc: pgsql-performance group <pgsql-performance@postgresql.org>
Sent: Sun, July 10, 2011 10:51:52 AM
Subject: Re: [PERFORM] query total time im milliseconds
On Sun, Jul 10, 2011 at 4:41 AM, Radhya sahal <rad_cs_2006@yahoo.com> wrote:
Dear all ,could any one help me?when i use pgadmin to exceute a query it shows the total time for query ..such as(select * form table_name.........)query total time is for example 100 msi want to know the command that can retentive the query total time in millisecondif i connect with postgresql from java using JDBCi need the query total time necessaryto use it in my projecti don't want run explian just querythank's
long startTime = System.currentTimeMillis();
//execute query
long executionTime = System.currentTimeMillis() - startTime;
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/