Re: Measuring time of select query - Mailing list pgsql-jdbc

From Bruce Momjian
Subject Re: Measuring time of select query
Date
Msg-id 200212021803.gB2I3mm10636@candle.pha.pa.us
Whole thread Raw
In response to Measuring time of select query  (Mariusz Wiktorczyk <kosmat@fanthom.math.put.poznan.pl>)
List pgsql-jdbc
Mariusz Wiktorczyk wrote:
> Hello!
> I have to measure the time of select query via the jdbc driver. I cannot
> do this using only java.sql interfaces :( Is there any possibility to do
> it using yours jdbc driver? Where can I find api docs to postgresql jdbc?
> Best regards
> Mariusz Wiktorczyk

I have a few solutions for you.  First, in 7.3, there is the
postgresql.conf variable 'log_duration' which will return the duration
of your query:

    test=> SET log_duration TO 'on';
    SET
    test=> SET client_min_messages TO 'log';
    LOG:  duration: 0.000682 sec
    SET
    test=> SELECT * FROM pg_language;
    LOG:  duration: 0.003959 sec
     lanname  | lanispl | lanpltrusted | lanplcallfoid | lanvalidator |
    lanacl
    ----------+---------+--------------+---------------+--------------+--------

     sql      | f       | t            |             0 |         2248 | {=U}
     internal | f       | f            |             0 |         2246 | {=}
     c        | f       | f            |             0 |         2247 | {=}
    (3 rows)

Also in 7.3, psql has \timing.  I don't know of any good way to do this
in < 7.3, nor in jdbc.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

pgsql-jdbc by date:

Previous
From: Thorsten Meinl
Date:
Subject: Bug in DatabaseMetaData.getColumns(...)??
Next
From: Nic Ferrier
Date:
Subject: Re: streaming result sets: progress