Re: [HACKERS] Re: [HACKERS] Re: [HACKERS] Re: [HACKERS] Is it necessary to rewrite table while increasing the scale of datatype numeric?

From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Greg Stark <stark(at)mit(dot)edu>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, wangshuo(at)highgo(dot)com(dot)cn, Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [HACKERS] Re: [HACKERS] Re: [HACKERS] Re: [HACKERS] Is it necessary to rewrite table while increasing the scale of datatype numeric?
Date: 2013-09-16 00:05:09
Message-ID: CAMkU=1w5qMi7KF9DdAokvjKpMDYHRKgQm2D93aJGphgMxUw-xA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Sep 6, 2013 at 11:47 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> > Sure, but the point is that 5.0000 is not the same as 5.000 today. If
> > you start whacking this around you'll be changing that behavior, I
> > think.
>
> Yeah. And please note that no matter what the OP may think, a lot of
> people *do* consider that there's a useful distinction between 5.000
> and 5.0000 --- it might indicate the number of significant digits in
> a measurement, for example. I do not see us abandoning that just to make
> certain cases of ALTER TABLE faster.
>

But note that the current behavior is worse in this regard. If you specify
a scale of 4 at the column level, than it is not possible to distinguish
between 5.000 and 5.0000 on a per-value basis within that column. If the
scale at the column level was taken as the maximum scale, not the only
allowed one, then that distinction could be recorded. That behavior seems
more sensible to me (metrologically speaking, regardless of alter table
performance aspects), but I don't see how to get there from here with
acceptable compatibility breakage.

My lesson from going over this thread is, just use numeric, not
numeric(x,y), unless you are storing currency or need compatibility with a
different database system (in which case, good luck with that).

Cheers,

Jeff

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Hannu Krosing 2013-09-16 00:08:38 Re: record identical operator
Previous Message Andrew Dunstan 2013-09-15 23:54:39 Re: Where to load modules from?