From: Josh Berkus <josh@agliodbs.com>
To: mallah@trade-india.com
Cc: pgsql-sql@postgresql.org
Subject: Re: Why is seq search preferred here by planner?
Date: Wed, 23 Apr 2003 12:53:52 -0700
Message-ID: <200304231253.52051.josh@agliodbs.com> (raw)
In-Reply-To: <1331.219.65.233.8.1051123905.squirrel@mail.trade-india.com>
References: <1220.219.65.235.51.1051114881.squirrel@mail.trade-india.com>
<200304231120.56699.josh@agliodbs.com>
<1331.219.65.233.8.1051123905.squirrel@mail.trade-india.com>
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 Berkus
Aglio Database Solutions
San Francisco
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-sql@postgresql.org
Cc: josh@agliodbs.com, mallah@trade-india.com
Subject: Re: Why is seq search preferred here by planner?
In-Reply-To: <200304231253.52051.josh@agliodbs.com>
* 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