On 05/30/15 01:20, Tomas Vondra wrote:
>
> Notice the cost - it's way lover than the previous plan (9.2 vs
> ~111k), yet this plan was not chosen. So either the change broke
> something (e.g. by violating some optimizer assumption), or maybe
> there's a bug somewhere else ...
After a bit more investigation, what I think is happening here is
add_path() does not realize this is a SEMI join and a single tuple is
enough, and discards the simple indexscan path in favor of the bitmap
index scan as that seems cheaper when scanning everything.
So not really a bug, but maybe 'consider_startup' would help?
--
Tomas Vondra http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services