Re: Why is seq search preferred here by planner? - Mailing list pgsql-sql

From Josh Berkus
Subject Re: Why is seq search preferred here by planner?
Date
Msg-id 200304231253.52051.josh@agliodbs.com
Whole thread Raw
In response to Re: Why is seq search preferred here by planner?  (<mallah@trade-india.com>)
Responses Re: Why is seq search preferred here by planner?  (<mallah@trade-india.com>)
List pgsql-sql
Mallah,

> > The reason that the planner is using a seq scan on
personal_account_details is  the same as the
> > reason for using  a seq scan on email_bank; the number of  rows which
match the condition,
> > about 150,000.   With that many qualifying  rows, a seq scan is faster.
>
>
> But there are two tables here , email_bank and personal_account_details
> in personal account details only one row is supposed to match a given userid
> as userid is the PKEY , why seq_scan there ? or am i getting the explain
wrong ?

It doesn't matter whether it's a primary key or not.  If your query or
subquery condition returns a large number/proportion of rows, a seq scan is
going to be faster than an index scan.

As far as userid being a key, this affects the planner's *join method*, *not*
how the database gets the rows.


--
-Josh BerkusAglio Database SolutionsSan Francisco



pgsql-sql by date:

Previous
From:
Date:
Subject: Re: Why is seq search preferred here by planner?
Next
From:
Date:
Subject: Re: Why is seq search preferred here by planner?