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

Поиск
Список
Период
Сортировка
От Jeff Davis
Тема Re: Suggested TODO: allow ALTERing of typemods without heap/index rebuild
Дата
Msg-id 1243889388.12209.39.camel@monkey-cat.sm.truviso.com
обсуждение исходный текст
Ответ на Suggested TODO: allow ALTERing of typemods without heap/index rebuild  (Josh Berkus <josh@agliodbs.com>)
Ответы Re: Suggested TODO: allow ALTERing of typemods without heap/index rebuild  (Greg Stark <stark@enterprisedb.com>)
Список pgsql-hackers
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 
> unnecessary.  Is this a special case of VARCHAR, or are there other 
> types where we should be allowing typemod changes without rebuilding?

NUMERIC(x, y) comes to mind, although that might be a more dangerous
case. If you turn a NUMERIC(5,0) into a NUMERIC(5,1), then '1.2' may be
stored as either '1' or '1.2' depending on whether you did the insert
before or after the change. That's because, with NUMERIC, it's not
really a constraint, but a rule for rounding.

There may be other interesting cases involving constraints. For
instance, if you have CHECK(i < 200), you should be able to add CHECK(i
< 1000) without an exclusive lock or recheck. Then, with an exclusive
lock, you can remove the original tighter constraint, but at least it
wouldn't have to recheck the entire table.

Not sure how much effort that is worth -- VARCHAR and NUMERIC typmods
are probably more common problems and easier to fix.

Regards,Jeff Davis



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Zdenek Kotala
Дата:
Сообщение: Re: list_head naming conflict gcc 4.2/perl/solaris
Следующее
От: Greg Stark
Дата:
Сообщение: Re: User-facing aspects of serializable transactions