Skip site navigation (1) Skip section navigation (2)

Re: TIMING A QUERY ???

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Sullivan <ajs(at)crankycanuck(dot)ca>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: TIMING A QUERY ???
Date: 2007-07-11 16:10:55
Message-ID: 26707.1184170255@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-performance
Andrew Sullivan <ajs(at)crankycanuck(dot)ca> writes:
> On Wed, Jul 11, 2007 at 08:21:40AM -0700, smiley2211 wrote:
>> How can I get the time it takes a query to execute - explain analyze is
>> taking over 5 hours to complete

> You can't get it any faster than what explain analyse does: it runs
> the query.  How else would you get the answer?

Well, on some platforms (ie consumer-grade PCs) explain analyze can be a
lot slower than just running the query, because of the overhead of all
those gettimeofday() calls it does.  El cheapo clock hardware is slow
to read.  (I think the problem is actually that the PC-standard hardware
API for clocks was designed back when taking a whole microsecond to read
the clock didn't seem like a problem.)

>> ...can I use \timing???  I don't get any time when using the
>> \timing option...

> How so?  It returns Time: N ms at the end of output for me.

Works for me too.

			regards, tom lane

In response to

Responses

pgsql-performance by date

Next:From: Gregory StarkDate: 2007-07-11 16:11:09
Subject: Re: TIMING A QUERY ???
Previous:From: Heikki LinnakangasDate: 2007-07-11 15:59:32
Subject: Re: PostgreSQL publishes first real benchmark

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group