Re: Recheck condition

From: "Josh Harrison" <joshques(at)gmail(dot)com>
To: "Martijn van Oosterhout" <kleptog(at)svana(dot)org>, "Josh Harrison" <joshques(at)gmail(dot)com>, "Postgresql General" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Recheck condition
Date: 2007-11-29 13:01:13
Message-ID: 8d89ea1d0711290501g699f65eew9da9031a0f2dfe23@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2007-11-29 13:15:07 Re: Recheck condition
Previous Message Edoardo Panfili 2007-11-29 12:45:11 Re: hibernate + postgresql ?