Thread: Measuring time of select query

Measuring time of select query

From
Mariusz Wiktorczyk
Date:
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


Re: Measuring time of select query

From
Bruce Momjian
Date:
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

Re: Measuring time of select query

From
Dave Cramer
Date:
Why can't you use the standard sql interface to measure the time of the
query?

Dave
On Sun, 2002-12-01 at 18:12, 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
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
--
Dave Cramer <Dave@micro-automation.net>