Tobias Brox <tobias@nordicbet.com> writes:
> This query puzzles me:
> select * from game where game_end>'2005-07-30' and state in (3,4);
> ...
> Now, how can the planner believe the game_by_state-index to be better?
I suspect the problem has to do with lack of cross-column statistics.
The planner does not know that state=4 is correlated with game_end,
and it's probably coming up with some bogus guesses about the numbers
of index rows visited in each case. You haven't given enough info to
quantify this, though.
regards, tom lane