Re: 7.4 - FK constraint performance

From: ow <oneway_111(at)yahoo(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: 7.4 - FK constraint performance
Date: 2004-02-13 01:03:41
Message-ID: 20040213010341.95282.qmail@web60801.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-sql

--- Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> According to this entry, your small_id column only contains the ten
> values 1..10, roughly evenly distributed. So why are you probing for
> 239??

Let's say we have City (small) and Person (large) tables. A new city was added
(mistakenly) with id=239, it does not have any "persons" assigned yet. Hence,
we want to remove the wrong "city" record.

In any case, one can't remove record from "small" unless there are NO records
in "large", RI will not allow it. The initial problem was that I tried to
delete a record from "small" and it was taking about 3 min to do that.

> The planner is certainly going to estimate a probe for an unspecified
> value as retrieving 10% of the table, and under that assumption it's
> quite right to use a seqscan.

Sounds pretty bad for my case. Any way to avoid the 10% scan?

Thanks

__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2004-02-13 01:10:36 Re: 7.4 - FK constraint performance
Previous Message Tom Lane 2004-02-13 00:42:58 Re: 7.4 - FK constraint performance

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2004-02-13 01:10:36 Re: 7.4 - FK constraint performance
Previous Message Tom Lane 2004-02-13 00:42:58 Re: 7.4 - FK constraint performance