Skip site navigation (1) Skip section navigation (2)

Re: how to change the index chosen in plan?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Rural Hunter <ruralhunter(at)gmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: how to change the index chosen in plan?
Date: 2012-06-08 14:10:58
Message-ID: 11881.1339164658@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-performance
Rural Hunter <ruralhunter(at)gmail(dot)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

In response to

Responses

pgsql-performance by date

Next:From: Rural HunterDate: 2012-06-08 14:23:12
Subject: Re: how to change the index chosen in plan?
Previous:From: Tom LaneDate: 2012-06-08 13:57:07
Subject: Re: non index use on LIKE on a non pattern string

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group