Re: Timing a query

From: "Greg Sabino Mullane" <greg(at)turnstep(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Timing a query
Date: 2001-11-27 17:07:53
Message-ID: E168ld8-00029R-00@mclean.mail.mindspring.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

> How recent? 7.2 beta?
> I tried it on 7.1.3 and didn't have it.

Yes, it is a 7.2 feature.

> Could you include the output of "EXPLAIN ANALYZE" I
> would like to see what it gives.

template1=# EXPLAIN ANALYZE SELECT foo,bar FROM baz;

NOTICE: QUERY PLAN:

Seq Scan on baz (cost=0.00..20.00 rows=1000 width=8) (actual time=0.01..0.01 rows=0 loops=1)
Total runtime: 0.06 msec

> This seems to be such a commonly needed task. Shouldn't this be
> incorporated into psql?

I still like my patch: it performs a little differently from the
EXPLAIN ANALYZE function. You turn it on and off with the
a "\m", and it records the time it takes everything to run,
even things like index creation, which EXPLAIN ANALYZE does not
handle. Plus, you don't have to go back and re-run the query
if you want to time it: it simply presents the timing information
after every query, until you turn the option off:

template1=# SELECT count(*) FROM baz;

count
- -------
15212

TOTAL TIME: 0.004665

template1=# CREATE INDEX foobar ON baz(waldo);

CREATE

TOTAL TIME: 0.011012

Greg Sabino Mullane
greg(at)turnstep(dot)com
PGP Key: 0x14964AC8 200111271204

-----BEGIN PGP SIGNATURE-----
Comment: http://www.turnstep.com/pgp.html

iQA/AwUBPAPITrybkGcUlkrIEQI7qQCggBpgODxZ6Sv2iUqYrMYAffEDpUoAn2G+
W7PQpuxwrXzy/jXsRiOhxb8i
=NxuD
-----END PGP SIGNATURE-----

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rich Shepard 2001-11-27 17:30:40 Re: Postgres 7.1.3 RPMs for RedHat 6.2 ?
Previous Message Lamar Owen 2001-11-27 17:05:33 Re: Postgres 7.1.3 RPMs for RedHat 6.2 ?