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

From: Greg Stark <stark(at)mit(dot)edu>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, wangshuo(at)highgo(dot)com(dot)cn, Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [HACKERS] Re: [HACKERS] Is it necessary to rewrite table while increasing the scale of datatype numeric?
Date: 2013-09-06 16:34:05
Message-ID: CAM-w4HN1YLqyuRf5q6dvfzHuvxHojpCqK2xtpGt2Bh1x+of6DQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Sep 5, 2013 at 8:53 PM, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>wrote:

> Greg Stark escribió:
>
> > The main difficulty is that Postgres is very extensible. So to implement
> > this you need to think bigger than NUMERIC. It should also be possible to
> > alter a column from varchar(5) to varchar(10) for example (but not the
> > other way around).
>
> We already allow that. See commits
> 8f9fe6edce358f7904e0db119416b4d1080a83aa and
> 3cc0800829a6dda5347497337b0cf43848da4acf
>

Ah, nice. i missed that.

So the issue here is that NUMERIC has an additional concept of scale that
is buried in the values and that this scale is set based on the typmod that
was in effect when the value was stored. If you change the typmod on the
column it currently rescales all the values in the table? There's even a
comment to that effect on the commit you pointed at.

But I wonder if we could just declare that that's not what the scale typmod
does. That it's just a maximum scale but it's perfectly valid for NUMERIC
data with lower scales to be stored in a column than the typmod says. In a
way the current behaviour is like bpchar but it would be nice if it was
more like varchar

--
greg

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2013-09-06 16:36:47 Re: [PERFORM] encouraging index-only scans
Previous Message Bruce Momjian 2013-09-06 16:30:56 Re: [PERFORM] encouraging index-only scans