From: | Jerry Sievers <jerry(at)jerrysievers(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Adding domain type with CHECK constraints slow on large table |
Date: | 2007-09-20 21:32:35 |
Message-ID: | m3sl593tvw.fsf@mama.jerrysievers.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
EnterpriseDB 8.2.4
create domain foodomain text check (value in ('val1', 'val2'));
alter table bigtable add foodomain;
I believe what's happening here is that the server doesn't realize
that the new column is going to have all nulls and that the check
constraint allows nulls. As such, the check evidently is being
evaluated for each row of the table.
I'm tempted to update pg_constraint around the alter table statement
to in the same transaction frob contypid to 0 and then back to the
domain pg_type.oid field value to (not yet tested), prevent the check
from being evaluated.
In our case, this hackery would save hours of downtime on a prod
system.
Comments?
PS: Sent this a few hours ago and never saw it. Sorry if duplicate.
--
-------------------------------------------------------------------------------
Jerry Sievers 732 365-2844 (work) Production Database Administrator
305 321-1144 (mobil WWW E-Commerce Consultant
From | Date | Subject | |
---|---|---|---|
Next Message | Scott Marlowe | 2007-09-20 21:33:25 | Re: autovacuum |
Previous Message | Erik Jones | 2007-09-20 21:14:35 | Re: autovacuum |