Tim Smith <reply_in_group(at)mouse-potato(dot)com> writes:
> SELECT id FROM bench WHERE data IN ('X', 'Y')
> To my surprise, when I tried this trick with PostgreSQL, it did not
> speed things up. In fact, it *massively* slowed down--it only is
> getting 13 selects in 3 seconds, searching for two at a time.
> What's going on here?
Likely it's switching from index to sequential scan because of a poor
estimate of how many rows will be returned. Have you ever ANALYZEd
the test table? Without either ANALYZE stats or a unique index,
the planner will certainly not think that the column is unique.
regards, tom lane