\timing interval - Mailing list pgsql-hackers

From Corey Huinker
Subject \timing interval
Date
Msg-id CADkLM=dbC4R8sbbuFXQVBFWoJGQkTEW8RWnC0PbW9nZsovZpJQ@mail.gmail.com
Whole thread Raw
Responses Re: \timing interval  (Peter Geoghegan <pg@heroku.com>)
Re: \timing interval  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
List pgsql-hackers
\timing is great.
\timing is helpful.
\timing has made me really good at mentally estimating numbers modulo 3600000.

Wouldn't it be great if we had a way of printing timing in more human friendly formats?

Attached is a patch that allows the following (new/interesting bits in bold):

# \timing off
Timing is off.
# select pg_sleep(1);
 pg_sleep
----------

(1 row)

# \timing
Timing is on.
# select pg_sleep(1);
 pg_sleep
----------

(1 row)

Time: 1002.959 ms
# \timing interval
Timing is interval.
# select pg_sleep(1);
 pg_sleep
----------

(1 row)

Time: 00:00:01.003
# \timing
Timing is off.


As demonstrated, "interval" toggles to "off". There is no way to toggle to "interval".

I'm pretty flexible on how something like this gets invoked. We could leave timing alone and create a format variable. We could actually leverage the pre-existing interval-to-string code, etc.

Note: the current patch includes no doc changes. I'd figure I'd wait to do that after this patch or another gains some traction.
Attachment

pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: SELECT DISTINCT never uses an index?
Next
From: Robert Haas
Date:
Subject: Re: [PATCH] add option to pg_dumpall to exclude tables from the dump