Re: [HACKERS] Suggested TODO: allow ALTERing of typemods without heap/index rebuild

2009-06-02 Thread Dimitri Fontaine
Hi, Josh Berkus j...@agliodbs.com writes: The stumbling block has been to identify a reasonably clean way of determining which datatype changes don't require a scan. Yep. One possibility I'm thinking is supplying a function for each type which takes two typemods (old and new) and returns a

[HACKERS] Suggested TODO: allow ALTERing of typemods without heap/index rebuild

2009-06-01 Thread Josh Berkus
All, I just realized that even if you do this: table foo ( id serial, bar varchar(200) ) ALTER TABLE foo ALTER COLUMN bar TYPE VARCHAR(1000) ... it triggers a heap index rebuild, even though it's completely unnecessary. Is this a special case of VARCHAR, or are

Re: [HACKERS] Suggested TODO: allow ALTERing of typemods without heap/index rebuild

2009-06-01 Thread Tom Lane
Josh Berkus j...@agliodbs.com writes: I just realized that even if you do this: ALTER TABLE foo ALTER COLUMN bar TYPE VARCHAR(1000) ... it triggers a heap index rebuild, even though it's completely unnecessary. Yeah, this has been discussed before; I think it's even in the TODO list. The

Re: [HACKERS] Suggested TODO: allow ALTERing of typemods without heap/index rebuild

2009-06-01 Thread Jeff Davis
On Mon, 2009-06-01 at 13:26 -0700, Josh Berkus wrote: All, I just realized that even if you do this: table foo ( id serial, bar varchar(200) ) ALTER TABLE foo ALTER COLUMN bar TYPE VARCHAR(1000) ... it triggers a heap index rebuild, even though it's completely

Re: [HACKERS] Suggested TODO: allow ALTERing of typemods without heap/index rebuild

2009-06-01 Thread Guillaume Smet
On Mon, Jun 1, 2009 at 10:40 PM, Tom Lane t...@sss.pgh.pa.us wrote: We could certainly put in a quick hack that just covered a few of the cases for built-in types, but it's not very pleasing ... Jonah proposed a patch for that a long time ago. See

Re: [HACKERS] Suggested TODO: allow ALTERing of typemods without heap/index rebuild

2009-06-01 Thread Josh Berkus
Yeah, this has been discussed before; I think it's even in the TODO list. I couldn't find it. At least, not under data types, and also not with the keyword typemod. Anyone see it? The stumbling block has been to identify a reasonably clean way of determining which datatype changes don't

Re: [HACKERS] Suggested TODO: allow ALTERing of typemods without heap/index rebuild

2009-06-01 Thread Jeff Davis
On Mon, 2009-06-01 at 14:39 -0700, Josh Berkus wrote: Note that this doesn't deal with the special case of VARCHAR--TEXT, but just with changing typemods. Are there other cases of data *type* conversions where no check or rebuild is required? Otherwise we might just special case

Re: [HACKERS] Suggested TODO: allow ALTERing of typemods without heap/index rebuild

2009-06-01 Thread Josh Berkus
Jeff, I observe that the casts (VARCHAR - TEXT and TEXT - VARCHAR) are marked WITHOUT FUNCTION. If that's the case, can't we use that to say that no heap rebuild is required? Perhaps we'll need to combine this with the typmod checks to see if we need to check the heap. yeah, you're right ..

Re: [HACKERS] Suggested TODO: allow ALTERing of typemods without heap/index rebuild

2009-06-01 Thread Tom Lane
Josh Berkus j...@agliodbs.com writes: yeah, you're right .. that would give us a short list of conversions which don't require a rewrite.However, as Tom points out, that doesn't mean that they might not need a reindex (as well as OID, there's also XML). Um. I had actually forgotten

Re: [HACKERS] Suggested TODO: allow ALTERing of typemods without heap/index rebuild

2009-06-01 Thread Tom Lane
Josh Berkus j...@agliodbs.com writes: Yeah, this has been discussed before; I think it's even in the TODO list. I couldn't find it. At least, not under data types, and also not with the keyword typemod. Anyone see it? It's the last item under ALTER: * Don't require table rewrite on ALTER