Re: Help with details of what happens when I create a constraint NOT VALID

From: Marti Raudsepp <marti(at)juffo(dot)org>
To: Bill Moran <wmoran(at)potentialtech(dot)com>
Cc: PG-General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: Help with details of what happens when I create a constraint NOT VALID
Date: 2014-01-24 08:22:22
Message-ID: CABRT9RAvQnVA8pDUtr_SzyVk7x+Z6iuC0YMufLqn4cY12vPhig@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Jan 23, 2014 at 3:46 PM, Bill Moran <wmoran(at)potentialtech(dot)com> wrote:
> It was suggested that
> leaving the constraints as NOT VALID might affect the planner, causing
> it to use less optimal plans because it doesn't think it can trust
> the constraint. Is this true?

AFAICT the planner doesn't currently rely on FOREIGN KEY constriants
for anything, so there's no downside to leaving those NOT VALID.

UNIQUE constraints affect the planner the most, but they must always
be valid anyway.

If you use table inheritance (partitioning), then valid CHECK
constraints are necessary to use that effectively.

> It has also been suggested that manually changing the status to valid
> in the catalog without going through the validation process could cause
> problems

It's unsupported: if you break something when manually messing with
the system catalog, you get to keep the pieces and people will just
tell you "we told you so". But if you know what you're doing, it's OK.
Just make sure you double-check the source code that you're not
missing something critical that it does.

Regards,
Marti

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Emmanuel Medernach 2014-01-24 09:20:37 postgres-fdw questions
Previous Message Thomas Kellerer 2014-01-24 07:33:21 Re: Fully-automatic streaming replication failover when master dies?