Adding a nullable DOMAIN column w/ CHECK

From: Marko Tiikkaja <marko(at)joh(dot)to>
To: PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org>
Cc: Joe Van Dyk <joe(at)tanga(dot)com>
Subject: Adding a nullable DOMAIN column w/ CHECK
Date: 2014-09-06 00:01:32
Message-ID: 540A4EDC.1060008@joh.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

First of all, sorry about breaking the thread; I don't subscribe to
-general so I can't copy the original email. This is in response to the
problem here:
http://www.postgresql.org/message-id/CACfv+p+8dToaR7h06_M_YMjpV5Na-CQq7kN=KgJq_k84H7UHWA@mail.gmail.com

Attached is a very ugly proof-of-concept patch of how this could work.
With this applied, the ALTER TABLE becomes fast:

=# create domain test_domain numeric check (value > 0);
CREATE DOMAIN
Time: 2,443 ms
=# create table test_domain_table as select generate_series(1, 2000000);
SELECT 2000000
Time: 1802,681 ms
=# alter table test_domain_table add column t test_domain;
ALTER TABLE
Time: 4,991 ms

The patch is obviously a load of horse crap, but does anyone have any
objections to the general approach of making this pattern faster? To do
this optimization we do have to assume that CHECKs in DOMAINs are at
least STABLE, but I don't see that as a problem; those should be
IMMUTABLE anyway, I think.

.marko

Attachment Content-Type Size
alter_table_add_domain.patch text/x-patch 2.1 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen Frost 2014-09-06 01:52:02 Re: A mechanism securing web applications in DBMS
Previous Message Bruce Momjian 2014-09-05 23:39:36 Re: Need Multixact Freezing Docs