Re: Is it necessary to rewrite table while increasing the scale of datatype numeric? - Mailing list pgsql-hackers

From Noah Misch
Subject Re: Is it necessary to rewrite table while increasing the scale of datatype numeric?
Date
Msg-id 20130906034704.GA161858@tornado.leadboat.com
Whole thread Raw
In response to Re: [HACKERS] Is it necessary to rewrite table while increasing the scale of datatype numeric?  (Jeff Janes <jeff.janes@gmail.com>)
Responses Re: [HACKERS] Is it necessary to rewrite table while increasing the scale of datatype numeric?
List pgsql-hackers
On Thu, Sep 05, 2013 at 10:41:25AM -0700, Jeff Janes wrote:
> In order to avoid the rewrite, the code would have to be changed to
> look up the column definition and if it specifies the scale, then
> ignore the per-row n_header, and look at the n_header only if the
> column is NUMERIC with no precision or scale.  That should
> conceptually be possible, but I don't know how hard it would be to
> implement--it sounds pretty invasive to me.  Then if the column was
> altered from NUMERIC with scale to be a plain NUMERIC, it would have
> to rewrite the table to enforce the row-wise scale to match the old
> column-wise scale.  Where as now that alter doesn't need a re-write.
> I don't know if this would be an overall gain or not.

Invasive indeed.  The type-supplementary data would need to reach essentially
everywhere we now convey a type OID.  Compare the invasiveness of adding
collation support.  However, this is not the first time it would have been
useful.  We currently store a type OID in every array and composite datum.
That's wasteful and would be unnecessary if we reliably marshalled similar
information to all the code needing it.  Given a few more use cases, the
effort would perhaps start to look credible relative to the benefits.

--
Noah Misch
EnterpriseDB                                 http://www.enterprisedb.com



pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [PERFORM] encouraging index-only scans
Next
From: Josh Berkus
Date:
Subject: Re: proposal: Set effective_cache_size to greater of .conf value, shared_buffers