The answer is "it depends". Postgres has a cost based planner, it will
> For example if I have a table Person with 3 fields (name,city_id,age). And
> the table contains 1000 rows. The table has 2 indexes city_id and age
> If I have a query :
> SELECT * FROM PERSON WHERE city_id=5 AND AGE=30
estimate the costs of each different way of getting the result and use
the cheapest. The factors that are important is how many rows each
condition will match.
Given your table is only 8MB, the system may decide that it's all in
memory and just do a scan.
Or it maybe see that city_id is almost unique and use that index and
check the matches for the second condition. Or vice-versa.
Or maybe it will scan both indexes, calculate the intersection and then
looks up the matches in the heap (with a recheck).
Okay....So If I have a query like the above and the query plan shows a 'recheck condition' and bitmap scan, then does that mean it scans the indexes first to get the intermediate results and goto the heap only for the final data?
Thanks
jo