Re: Index usage question

From: "Mitch Vincent" <mvincent(at)cablespeed(dot)com>
To: "Jefim Matskin" <mjefim(at)sphera(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Index usage question
Date: 2001-09-04 17:19:43
Message-ID: 00b801c13565$ca31b9b0$1e51000a@mitch
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> When I execute the explain on a simple join query I see that the indices
are
> NOT used for
> the join:
>
> explain select tblAccountAvailablePlugins.nAcctPluginDirID,
> tblAccountPluginDir.nAcctPluginDirID FROM tblAccountAvailablePlugins,
> tblAccountPluginDir WHERE
>
tblAccountPluginDir.nAcctPluginDirID=tblAccountAvailablePlugins.nAcctPluginD
> irID;
> NOTICE: QUERY PLAN:
>
> Hash Join (cost=21.45..640.50 rows=6530 width=8)
> -> Seq Scan on tblaccountavailableplugins (cost=0.00..187.52
rows=10452
> width=4)
> -> Hash (cost=18.76..18.76 rows=1076 width=4)
> -> Seq Scan on tblaccountplugindir (cost=0.00..18.76 rows=1076
> width=4)
>
> EXPLAIN
>
> can anyone explain me what is wrong with my query?

If you haven't VACUUM ANALYZE 'd recently, do so to update the statistics on
your table(s)... The reason it's doing a sequential scan is that a seq scan
is (probably) better if that query really does return as many rows as it
thinks it does.. After you update the statistics, try again and see what the
query plan is then..

-Mitch

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message E Kolve 2001-09-04 17:22:19 Re: many junction tables
Previous Message Gabriel Fernandez 2001-09-04 17:08:04 FOREIGN KEY: difference between NOT DEFERRABLE and INITIALLY IMMEDIATE