Re: optimizer choosing the wrong index
| От | Tom Lane | 
|---|---|
| Тема | Re: optimizer choosing the wrong index | 
| Дата | |
| Msg-id | 29483.1278615195@sss.pgh.pa.us обсуждение исходный текст | 
| Ответ на | Re: optimizer choosing the wrong index (Merlin Moncure <mmoncure@gmail.com>) | 
| Список | pgsql-general | 
Merlin Moncure <mmoncure@gmail.com> writes:
> I think so too, but suppose we wanted to force the other plan anyways:
> select * from ps where (client_id, expires_on) >=
> ('123', '24.11.2010'::timestamp) and (client_id, expires_on) < ('123',
> null) order by client_id, expires_on;
A simpler way to force use of the other index is
    begin;
    drop index wrong_index;
    explain analyze my_query;
    rollback;
> I'd be curious to see explain analyze (not explain) comparisons for
> the 'wrong' index vs above.  I suspect the plan is 'correct' for
> *most* of the data, or you cherry picked (or unluckily drew) a bad
> value to get your 22 times speed difference.
Yeah, it would be interesting to see explain analyze output for both
cases, and for a few different values of the expires_on date if this
one is unlike the typical value.
            regards, tom lane
		
	В списке pgsql-general по дате отправления: