Re: DEFERRABLE NOT NULL constraint

From: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
To: Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>
Cc: "Gavan Schneider *EXTERN*" <pg-gts(at)snkmail(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: DEFERRABLE NOT NULL constraint
Date: 2013-02-07 09:33:37
Message-ID: CAEZATCX-pw+i_wOYsJ0+KKuV3DzgV1si3R6NUTFcQNm_JPyOpg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 7 February 2013 08:50, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> wrote:
> That's actually a sensible default, because there are consequences to
> making a constraint deferrable --- it can hurt performance if a large
> number of rows need to be queued up for later checking...

Just to clarify --- PostgreSQL goes to some effort to avoid queuing up
re-checks of deferred constraints if they are unnecessary. So, for
example, in the case of primary key/unique constraints, the
performance in the deferrable and non-deferrable cases are about the
same provided that none of the inserted/updated rows violate the
uniqueness check at insert/update time. The real performance hit comes
in if the constraint is deferrable, and a large number of new rows
violate the constraint temporarily, and so need to be re-checked
later.

Regards,
Dean

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Chris Travers 2013-02-07 09:38:26 feature requests (possibly interested in working on this): functional foreign keys
Previous Message Bèrto ëd Sèra 2013-02-07 09:14:16 Re: DEFERRABLE NOT NULL constraint