psql microsecond timing patch

Started by Greg Sabino Mullanealmost 25 years ago3 messagespatches
Jump to latest
#1Greg Sabino Mullane
greg@turnstep.com

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

This is a small patch to allow you to time your queries in
psql. Myself and some others have been using it and find it
useful for telling how long an actual specific query takes,
as opposed to EXPLAIN which just does an estimate. Using the
two together is a good way to tweak sql and indices. Even
if not deemed useful, it should be good practice in learning
to submit patches. :)

(I called it "microsecond timing" because "m" was one of the
few letters still available as a backslash command that
had some mnemonic potential.)

Thanks,
Greg Sabino Mullane
greg@turnstep.com 200109270943
PGP Key: 0x14964AC8

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

iQA/AwUBO7NHE7ybkGcUlkrIEQIq9wCfSSsozUx5U55EPUsuBz5XZErfcIEAnAu7
FrtN+K+rtXIgTmRn9MABLC3i
=UXkx
-----END PGP SIGNATURE-----

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Greg Sabino Mullane (#1)
Re: psql microsecond timing patch

greg@turnstep.com writes:

This is a small patch to allow you to time your queries in
psql. Myself and some others have been using it and find it
useful for telling how long an actual specific query takes,
as opposed to EXPLAIN which just does an estimate.

Hmm. Is there any value in this now that we have EXPLAIN ANALYZE?

Microsecond-level timing on the client side seems like a dubious
proposition anyway ...

regards, tom lane

#3Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#2)
Re: psql microsecond timing patch

greg@turnstep.com writes:

This is a small patch to allow you to time your queries in
psql. Myself and some others have been using it and find it
useful for telling how long an actual specific query takes,
as opposed to EXPLAIN which just does an estimate.

Hmm. Is there any value in this now that we have EXPLAIN ANALYZE?

Microsecond-level timing on the client side seems like a dubious
proposition anyway ...

FYI, EXPLAIN ANALYZE will appear in 7.2:

test=> EXPLAIN ANALYZE SELECT * FROM pg_class;
NOTICE: QUERY PLAN:

Seq Scan on pg_class (cost=0.00..3.01 rows=101 width=115) (actual
time=0.06..1.97 rows=101 loops=1)
Total runtime: 2.51 msec

EXPLAIN

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026