Forcefully adding a CHECK constrained - Mailing list pgsql-general

From Catalin(ux) M. BOIE
Subject Forcefully adding a CHECK constrained
Date
Msg-id alpine.LFD.2.02.1205151239120.24617@mail.embedromix.ro
Whole thread Raw
Responses Re: Forcefully adding a CHECK constrained
Re: Forcefully adding a CHECK constrained
List 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/

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Vacuum does not show in pg_stat_all_tables
Next
From: Condor
Date:
Subject: Re: Vacuum does not show in pg_stat_all_tables