Re: 7.4 - FK constraint performance

From: Richard Huxton <dev(at)archonet(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Rod Taylor <rbt(at)rbt(dot)ca>
Cc: ow <oneway_111(at)yahoo(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: 7.4 - FK constraint performance
Date: 2004-02-13 07:22:17
Message-ID: 200402130722.17663.dev@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-sql

On Friday 13 February 2004 04:25, Tom Lane wrote:
> Rod Taylor <rbt(at)rbt(dot)ca> writes:
> > Statistics say there are 10 values. Statistics list the 10 most common
> > values (all of them). Given this, would it not be reasonable to assume
> > that 239 is a recent addition (if there at all) to the table and not
> > very common?
>
> We don't know that it's 239 when we make the plan. In order to know
> that, we'd have to abandon caching of RI check query plans and re-plan
> for each row. That strikes me as inevitably a losing proposition.

In this precise example, could you not:
1. Check index for value
2. If found, seq-scan

Of course that's only going to be a sensible thing to do if you're expecting
one of two results:
1. Value not there
2. Lengthy seq-scan if it is there
--
Richard Huxton
Archonet Ltd

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dennis Haney 2004-02-13 08:27:31 Re: Proposed Query Planner TODO items
Previous Message Bruce Momjian 2004-02-13 04:53:22 Re: [PATCHES] log session end - again

Browse pgsql-sql by date

  From Date Subject
Next Message Tomasz Myrta 2004-02-13 08:07:15 Re: How to avoid nulls while writing string for dynamic query
Previous Message Kumar 2004-02-13 07:13:26 Re: How to avoid nulls while writing string for dynamic query