From: | Corey Huinker <corey(dot)huinker(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Gerdan Santos <gerdan(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: \timing interval |
Date: | 2016-09-01 18:51:53 |
Message-ID: | CADkLM=cdWod1M_2_8H1PjPxxF0qZ+-prmrs2BTT8Y6nbyXUhUw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Thu, Sep 1, 2016 at 2:43 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> I wrote:
> > Sorry, that probably added no clarity at all, I was confusing
> > seconds with milliseconds in the example values :-(
>
> After a bit of further fooling with sample values, I propose this
> progression:
>
> Time: 0.100 ms
> Time: 1.200 ms
> Time: 1001.200 ms (0:01.001)
> Time: 12001.200 ms (0:12.001)
> Time: 60001.200 ms (1:00.001)
> Time: 720001.200 ms (12:00.001)
> Time: 3660001.200 ms (1:01:00.001)
> Time: 43920001.200 ms (12:12:00.001)
> Time: 176460001.200 ms (2 01:01:00.001)
> Time: 216720001.200 ms (2 12:12:00.001)
> Time: 10000000000000000000.000 ms (115740740740 17:46:40.000)
>
> Note that times from 1 second to 1 hour all get the nn:nn.nnn
> treatment. I experimented with these variants for sub-minute times:
>
> Time: 1001.200 ms (1.001)
> Time: 12001.200 ms (12.001)
> Time: 1001.200 ms (1.001 s)
> Time: 12001.200 ms (12.001 s)
>
> but it seems like the first variant is not terribly intelligible and
> the second variant is inconsistent with what happens for longer times.
> Adding a zero minutes field is a subtler way of cueing the reader that
> it's mm:ss.
>
> regards, tom lane
>
Well, if we're looking to be consistent, here's what interval does now:
# select '1 second 1 millisecond'::interval, '1 minute 2
milliseconds'::interval, '1 hour 30 milliseconds'::interval, '1 day 1 hour
999 milliseconds'::interval, '1 week 1 day 1 hour'::interval;
interval | interval | interval | interval |
interval
--------------+--------------+-------------+--------------------+-----------------
00:00:01.001 | 00:01:00.002 | 01:00:00.03 | 1 day 01:00:00.999 | 8 days
01:00:00
(1 row)
Should we just plug into whatever code that uses? It's slightly different:
# select interval '10000000000000000000.001 milliseconds'::interval;
ERROR: interval field value out of range: "10000000000000000000.001
milliseconds"
LINE 1: select interval '10000000000000000000.001 milliseconds'::int...
^
# select interval '216720001.200 milliseconds';
interval
---------------
60:12:00.0012
(1 row)
# select interval '176460001.200 ms';
interval
---------------
49:01:00.0012
(1 row)
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2016-09-01 19:01:03 | Re: \timing interval |
Previous Message | Tom Lane | 2016-09-01 18:51:29 | Re: \timing interval |