Forcefully adding a CHECK constrained

From: "Catalin(ux) M(dot) BOIE" <catab(at)embedromix(dot)ro>
To: pgsql-general(at)postgresql(dot)org
Subject: Forcefully adding a CHECK constrained
Date: 2012-05-15 09:52:28
Message-ID: alpine.LFD.2.02.1205151239120.24617@mail.embedromix.ro
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello.

When I discovered the wonders of partitioning I quickly jumped on-board.
I had big tables used for statistics and a split was needed.

I created the parent, I linked the big table with this new parent and I
added other childs, per month.

Example:
new_stats - parent (empty)
old_stats - child, no CHECK
stats_2012_04 - child, with CHECK
stats_2012_05 - child, with CHECK

The old_stats is so big that I cannot afford to add a check constraint.
But, I know that all values of the itime field are before 2012_04, so,
would be great if I could run something like:

ALTER TABLE old_stats ADD CONSTRAINT xxx CHECK (itime < 2012_04_timestamp)
FORCE;

Of course I can create an index concurrently and then add constraint using
"USING INDEX", but this means a scan of the big table.

I never looked at PostgreSQL sources, but the commit
Enable CHECK constraints to be declared NOT VALID
http://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=897795240cfaaed724af2f53ed2c50c9862f951f
inspired me to dive.
Is PostgreSQL's team willing to accept such a feature?

Thank you for your time!

(Please keep me on cc)

--
Catalin(ux) M. BOIE
http://kernel.embedromix.ro/

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Willy-Bas Loos 2012-05-15 10:37:02 Re: dblink.sql and Linux
Previous Message chinnaobi 2012-05-15 09:11:45 Re: HotStandby --Advice needed