Unix Technical Forum

GUC time unit spelling a bit inconsistent

This is a discussion on GUC time unit spelling a bit inconsistent within the pgsql Hackers forums, part of the PostgreSQL category; --> It seems that time-based GUC variables can be spelled like 1h but not 1hr 1min but not 1m 1s ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Hackers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-12-2008, 09:09 AM
Tom Lane
 
Posts: n/a
Default GUC time unit spelling a bit inconsistent

It seems that time-based GUC variables can be spelled like
1h but not 1hr
1min but not 1m
1s but not 1sec
This is inconsistent and confusing. I don't object to the ones on the
left as being the standard spellings for printout, but if we're not
going to have a simple uniform rule like "shortest possible
abbreviation" then we ought to accept plausible alternatives on input.

I got burnt by this just now because I looked at the autovacuum_naptime
setting in postgresql.conf, which is shown as '1min', and figured I
could change it to '5sec'.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-12-2008, 09:10 AM
Alvaro Herrera
 
Posts: n/a
Default Re: GUC time unit spelling a bit inconsistent

Tom Lane wrote:
> It seems that time-based GUC variables can be spelled like
> 1h but not 1hr
> 1min but not 1m
> 1s but not 1sec
> This is inconsistent and confusing. I don't object to the ones on the
> left as being the standard spellings for printout, but if we're not
> going to have a simple uniform rule like "shortest possible
> abbreviation" then we ought to accept plausible alternatives on input.
>
> I got burnt by this just now because I looked at the autovacuum_naptime
> setting in postgresql.conf, which is shown as '1min', and figured I
> could change it to '5sec'.


Some random observations:

- I was bitten by this too, not long ago, and took me a while to
understand why. Should we at least log a HINT or something?

- We do allow preffixes in certain cases. For example I can specify a
naptime in milliseconds:
$ postmaster -c autovacuum_naptime=2000ms
and it shows up as "2s" in SHOW.

However, preffixing with M or K does not work:
$ postmaster -c autovacuum_naptime=2Ms
FATAL: parameter "autovacuum_naptime" requires an integer value
$ postmaster -c autovacuum_naptime=2Ks
FATAL: parameter "autovacuum_naptime" requires an integer value

"millihours" doesn't seem to work either.

- In shared_buffers, these work:
8MB
8 MB

These don't work:
8M B
8 M B
8mB
8m
8M

I think this means we could safely use "m" as an abbreviation for
"minutes", where it is not preffixed by anything else (so "mm" would
not mean milliminutes, nor millimeters). It is not confused with
meters because we don't use longitude anywhere in our configuration
settings and are not likely to start doing so in the foreseeable
future.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-12-2008, 09:10 AM
Tom Lane
 
Posts: n/a
Default Re: GUC time unit spelling a bit inconsistent

Alvaro Herrera <alvherre@commandprompt.com> writes:
> - I was bitten by this too, not long ago, and took me a while to
> understand why. Should we at least log a HINT or something?


Yeah, a HINT listing the allowed spellings of the unit would go a long
way here.

> However, preffixing with M or K does not work:


It's case-sensitive. We had that argument already, but I still think
this decision was wrong.

> - In shared_buffers, these work:
> 8MB
> 8 MB


> These don't work:
> 8M B
> 8 M B


Looking at the code, spaces before the unit are allowed, but not spaces
within or after. I agree with disallowing embedded spaces, I think,
but not allowing trailing spaces is inconsistent with our practice in
other cases (in particular, these very same variables, when written as
pure numbers...)

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-12-2008, 09:10 AM
Peter Eisentraut
 
Posts: n/a
Default Re: GUC time unit spelling a bit inconsistent

Am Montag, 18. Juni 2007 16:16 schrieb Tom Lane:
> It seems that time-based GUC variables can be spelled like
> ********1h******but not*********1hr
> ********1min****but not*********1m
> ********1s******but not*********1sec


The left columns are the standard units. The right columns are just randomly
made up AFAICT. If we allow that, what's someone to stop from making up
their own set?

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-12-2008, 09:10 AM
Gregory Stark
 
Posts: n/a
Default Re: GUC time unit spelling a bit inconsistent

"Tom Lane" <tgl@sss.pgh.pa.us> writes:

> It's case-sensitive. We had that argument already, but I still think
> this decision was wrong.


I thought the consensus was that it should change.


--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com


---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-12-2008, 09:10 AM
Tom Lane
 
Posts: n/a
Default Re: GUC time unit spelling a bit inconsistent

Peter Eisentraut <peter_e@gmx.net> writes:
> Am Montag, 18. Juni 2007 16:16 schrieb Tom Lane:
>> It seems that time-based GUC variables can be spelled like
>> 1h but not 1hr
>> 1min but not 1m
>> 1s but not 1sec


> The left columns are the standard units.


Standard according to whom? In time-related contexts (eg ISO 8601)
I'd expect just "h" "m" and "s".

Since there's no likelihood that anyone would think autovacuum_naptime
is measured in meters, I think insisting that it must not be written as
"1m" is just pedantry.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 04-12-2008, 09:10 AM
Peter Eisentraut
 
Posts: n/a
Default Re: GUC time unit spelling a bit inconsistent

Am Montag, 18. Juni 2007 19:03 schrieb Tom Lane:
> Standard according to whom?


ISO 31 a.k.a. SI

> In time-related contexts (eg ISO 8601) I'd expect just "h" "m" and "s".


ISO 8601 appears to use a slightly different syntax for writing timespans. I
would not object if anyone added support for that.

> Since there's no likelihood that anyone would think autovacuum_naptime
> is measured in meters, I think insisting that it must not be written as
> "1m" is just pedantry.


I'm pretty sure a lot of people would initially be confused why anyone would
write time in meters, let alone those that might associate it with memory
units. In my subjective view (and I acknowledge that we have all been
educated in different ways), writing "1m" for a time quantity is meaningless
and an error.

Standards exist for these things, and we have a fine tradition for choosing
standards in favor of randomness.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 04-12-2008, 09:10 AM
Peter Eisentraut
 
Posts: n/a
Default Re: GUC time unit spelling a bit inconsistent

Am Montag, 18. Juni 2007 18:16 schrieb Alvaro Herrera:
> - We do allow preffixes in certain cases.


It would certainly be fun to have a general units system, which you could use
for configuration and data in general. But that would definitely require
that we stay strict on what we allow, or you could do no meaningful things
with this in a safe way.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

http://www.postgresql.org/about/donate

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 04-12-2008, 09:10 AM
Gregory Stark
 
Posts: n/a
Default Re: GUC time unit spelling a bit inconsistent

"Peter Eisentraut" <peter_e@gmx.net> writes:

> I'm pretty sure a lot of people would initially be confused why anyone would
> write time in meters, let alone those that might associate it with memory
> units. In my subjective view (and I acknowledge that we have all been
> educated in different ways), writing "1m" for a time quantity is meaningless
> and an error.


That's an argument for why Postgres maybe shouldn't print times with "m" for
minutes -- though I for one would prefer it. Or why it might not be a
particularly good idea for a sysadmin to use "m" given the choice.

But to argue that Postgres should refuse "m" when presented with it you would
have to say there's a substantial chance that the user didn't mean minutes and
that there was a risk Postgres would do something bad that outweighs giving
users who do want minutes getting what they want.

Frankly, I think I see "m" as an abbreviation for minutes *more* often than
"min" anyways. I see times written as 2h30m quite frequently and then there's
precedent like this:

$ time echo

real 0m0.000s
user 0m0.000s
sys 0m0.000s


--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com


---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 04-12-2008, 09:10 AM
Simon Riggs
 
Posts: n/a
Default Re: GUC time unit spelling a bit inconsistent

On Mon, 2007-06-18 at 20:02 +0200, Peter Eisentraut wrote:
> Am Montag, 18. Juni 2007 19:03 schrieb Tom Lane:
> > In time-related contexts (eg ISO 8601) I'd expect just "h" "m" and "s".

>
> ISO 8601 appears to use a slightly different syntax for writing timespans. I
> would not object if anyone added support for that.
>
> > Since there's no likelihood that anyone would think autovacuum_naptime
> > is measured in meters, I think insisting that it must not be written as
> > "1m" is just pedantry.

>
> I'm pretty sure a lot of people would initially be confused why anyone would
> write time in meters,


Nobody at all is going to be confused on that point because the physical
quantity of autovacuum_naptime is clearly Time and therefore "m" would
mean minutes. Time and Distance are fairly distinct and not easily
confused, except by those with a grounding in Riemannian manifolds.

All parameters for which we can input a time unit are clearly named as
such and there would be no confusion anywhere.

You are absolutely 100% right about your units and you've clearly done
your homework, but the standard PostgreSQL should apply here is
Usability, not the absolute letter of the law as laid down in a dusty
old document. There is nothing to be gained by adherence to ISO 31 or
ISO 8601, but certainly something to be lost.

Please lets be real about this and allow the abbreviations suggested.

Your efforts to introduce units is excellent and much appreciated by
all; please don't make them harder to use than the plain numbers were.

--
Simon Riggs
EnterpriseDB http://www.enterprisedb.com



---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:01 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com