pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andreas Pflug <pgadmin@pse-consulting.de>
To: Stephan Szabo <sszabo@megazone.bigpanda.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: Re: [GENERAL] 7.4Beta
Date: Fri, 15 Aug 2003 17:33:21 +0200
Message-ID: <3F3CFD41.7020508@pse-consulting.de> (raw)
In-Reply-To: <20030815073521.B19338-100000@megazone.bigpanda.com>
References: <20030815073521.B19338-100000@megazone.bigpanda.com>

Stephan Szabo wrote:

>On Fri, 15 Aug 2003, Andreas Pflug wrote:
>
>  
>
>>Stephan Szabo wrote:
>>
>>    
>>
>>>That really needs to be rewritten to do a single check over the table
>>>rather than running the constraint for every row.  I keep meaning to get
>>>around to it and never actually do. :(  I'm not sure that in practice
>>>you'll get a better plan at restore time depending on what the default
>>>statistics give you.
>>>
>>>      
>>>
>>This is clearly a case for a statement level trigger, as soon as
>>affected rows can be identified.
>>    
>>
>
>Well, I think single inserts might be more expensive (because the query is
>more involved for the table joining case) using a statement level trigger,
>so we'd probably want to profile the cases.
>  
>
This really depends. If a constraint is just a check on the 
inserted/updated column, so no other row needs to be checked, there's no 
faster way then the current row trigger. But FK constraints need to 
execute a query to retrieve the referenced row, and every RDBMS prefers 
to execute a single statement with many rows over many statements with a 
single row, because the first will profit from optimization. And even if 
only a single row is inserted or updated, there's still the need to 
lookup the reference.

Regards,
Andreas





view thread (30+ messages)  latest in thread

Message-ID: <3F3CFD41.7020508@pse-consulting.de>
Permalink:  ../3F3CFD41.7020508@pse-consulting.de/
Also on:    postgresql.org/message-id/3F3CFD41.7020508@pse-consulting.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: pgadmin@pse-consulting.de, sszabo@megazone.bigpanda.com
  Subject: Re: [GENERAL] 7.4Beta
  In-Reply-To: <3F3CFD41.7020508@pse-consulting.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox