how to change the index chosen in plan?

Поиск
Список
Период
Сортировка
От Rural Hunter
Тема how to change the index chosen in plan?
Дата
Msg-id 4FD1FF14.9060303@gmail.com
обсуждение исходный текст
Ответы Re: how to change the index chosen in plan?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-performance
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. So I re-wrote the query as below:
select a.* from a where a.aid in (select aid from b where bid=8) and
a.col1=33 a.col2=44
But surprisingly, postgresql didn't change the plan. it still chose to
index scan on a.col1. How can I re-wirte the query so postgresql will
scan on b.bid first?

В списке pgsql-performance по дате отправления:

Предыдущее
От: Cédric Villemain
Дата:
Сообщение: Re: non index use on LIKE on a non pattern string
Следующее
От: Tom Lane
Дата:
Сообщение: Re: non index use on LIKE on a non pattern string