Re: Order of enforcement of CHECK constraints? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Order of enforcement of CHECK constraints?
Date
Msg-id 1342.1427124792@sss.pgh.pa.us
Whole thread Raw
In response to Re: Order of enforcement of CHECK constraints?  (Fabrízio de Royes Mello <fabriziomello@gmail.com>)
Responses Re: Order of enforcement of CHECK constraints?  (Fabrízio de Royes Mello <fabriziomello@gmail.com>)
List pgsql-hackers
Fabrízio de Royes Mello <fabriziomello@gmail.com> writes:
> On Fri, Mar 20, 2015 at 4:37 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>>>> We could fix it by, say, having CheckConstraintFetch() sort the
>>>> constraints by name after loading them.

> Isn't better do this to read pg_constraint in name order?

> -   conscan = systable_beginscan(conrel, ConstraintRelidIndexId, true,
> +   conscan = systable_beginscan(conrel, ConstraintNameNspIndexId, true,

Surely not.  That would end up having to read *all* of pg_constraint, not
only the rows applicable to the current relation.

We could get the index to do the work for us if we changed it from an
index on conrelid to one on conrelid, conname.  However, seeing that that
would bloat the index by a factor of sixteen, it hardly sounds like a
free fix either.

I really think that a quick application of qsort is the best-performing
way to do this.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Jeff Janes
Date:
Subject: Re: Table-level log_autovacuum_min_duration
Next
From: Bruce Momjian
Date:
Subject: Re: Zero-padding and zero-masking fixes for to_char(float)