"Rigmor Ukuhe" <rigmor.ukuhe@finestmedia.com> writes:
>>> What causes this behaviour? is there any workaround? Suggestions?
At some point the planner is going to decide that one seqscan is cheaper
than repeated indexscans. At some point it'll be right ... but in this
case it seems its relative cost estimates are off a bit. You might try
reducing random_page_cost to bring them more into line with reality.
(But keep in mind that the reality you are measuring appears to be
small-table-already-fully-cached reality. On a large table you might
find that small random_page_cost isn't such a hot idea after all.)
regards, tom lane