Re: Recheck condition

Поиск
Список
Период
Сортировка
От Josh Harrison
Тема Re: Recheck condition
Дата
Msg-id 8d89ea1d0711290501g699f65eew9da9031a0f2dfe23@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Recheck condition  (Martijn van Oosterhout <kleptog@svana.org>)
Ответы Re: Recheck condition
Список pgsql-general


> 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

The answer is "it depends". Postgres has a cost based planner, it will
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

В списке pgsql-general по дате отправления:

Предыдущее
От: Edoardo Panfili
Дата:
Сообщение: Re: hibernate + postgresql ?
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: Recheck condition