From: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Tim Kane <tim(dot)kane(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Alter domain type / avoiding table rewrite |
Date: | 2019-04-16 14:55:40 |
Message-ID: | 6fa4216b-f1aa-b6d1-04fd-2089213f8311@aklaver.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 4/16/19 7:42 AM, Tom Lane wrote:
> Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> writes:
>> I suspect the OP wants the type to text with a CHECK constraint to allow
>> for increasing the length of field values in the future by just changing
>> the CHECK setting. If that is the case would changing the type to text
>> and then adding a CHECK NOT VALID work without too much pain?
>
> I don't think we really support NOT VALID on domain constraints do we?
I was not clear. I was thinking the OP could modify your suggestion.
Instead of:
old_type --> varchar(9) --> varchar(12)
doing:
old_type --> varchar(9) --> text --> CHECK ((length(VALUE) <= 12)) NOT VALID
>
> In any case, the point remains that domains are pretty inefficient
> compared to native types like varchar(12); partly because the system
> can't reason very well about arbitrary check constraints as compared
> to simple length constraints, and partly because the whole feature
> just isn't implemented very completely or efficiently. So you'll be
> paying *a lot* for some hypothetical future savings.
>
> (Having said that, you're already paying a fair chunk of that
> overhead with your existing domain type, so maybe it's not bothering
> you. But I'm worried that going from domain-without-check-constraint
> to domain-with-check-constraint is going to bite you.)
>
> regards, tom lane
>
--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Ron | 2019-04-16 15:04:58 | Re: Alter domain type / avoiding table rewrite |
Previous Message | Tom Lane | 2019-04-16 14:42:28 | Re: Alter domain type / avoiding table rewrite |