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

From: Jim Nasby <jim(at)nasby(dot)net>
To: Noah Misch <noah(at)leadboat(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>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Subject: Re: [HACKERS] Is it necessary to rewrite table while increasing the scale of datatype numeric?
Date: 2013-09-06 20:23:38
Message-ID: 522A39CA.90006@nasby.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 9/5/13 10:47 PM, Noah Misch wrote:
> 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.

Aren't there cases where PL/pgsql gets hosed by this? Or even functions in general?

I also have a vague memory of some features that would benefit from being able to have typemod info available at a tuple level in a table, not just for the entire table. Unfortunately I can't remember why we wanted that... (Alvaro, do you recall? I'm pretty sure it's something we'd discussed at some point.)
--
Jim C. Nasby, Data Architect jim(at)nasby(dot)net
512.569.9461 (cell) http://jim.nasby.net

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Korotkov 2013-09-06 20:30:05 Fix picksplit with nan values
Previous Message Jim Nasby 2013-09-06 20:10:06 Re: [PERFORM] encouraging index-only scans