Re: how to change the index chosen in plan? - Mailing list pgsql-performance

From Tom Lane
Subject Re: how to change the index chosen in plan?
Date
Msg-id 11881.1339164658@sss.pgh.pa.us
Whole thread Raw
In response to how to change the index chosen in plan?  (Rural Hunter <ruralhunter@gmail.com>)
Responses Re: how to change the index chosen in plan?  (Rural Hunter <ruralhunter@gmail.com>)
List pgsql-performance
Rural Hunter <ruralhunter@gmail.com> writes:
> I have a query like this:
> select a.* from a inner join b on a.aid=b.aid where a.col1=33 a.col2=44
> and b.bid=8
> postgresql selected the index on a.col1 then selected the index on
> b.bid. But in my situation, I know that the query will be faster if it
> chose the index on b.bid first since there are only a few rows with
> value 8.

If you know that and the planner doesn't, maybe ANALYZE is called for.

            regards, tom lane

pgsql-performance by date:

Previous
From: Tom Lane
Date:
Subject: Re: non index use on LIKE on a non pattern string
Next
From: Rural Hunter
Date:
Subject: Re: how to change the index chosen in plan?