Re: Index usage question - Mailing list pgsql-general

From Mitch Vincent
Subject Re: Index usage question
Date
Msg-id 00b801c13565$ca31b9b0$1e51000a@mitch
Whole thread Raw
In response to Index usage question  (Jefim Matskin <mjefim@sphera.com>)
List 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


pgsql-general by date:

Previous
From: E Kolve
Date:
Subject: Re: many junction tables
Next
From: Einar Karttunen
Date:
Subject: Re: Index usage question