Re: Recheck condition - Mailing list pgsql-general

From Alvaro Herrera
Subject Re: Recheck condition
Date
Msg-id 20071129131507.GJ4858@alvh.no-ip.org
Whole thread Raw
In response to Re: Recheck condition  ("Josh Harrison" <joshques@gmail.com>)
Responses Re: Recheck condition  ("Josh Harrison" <joshques@gmail.com>)
List pgsql-general
Josh Harrison escribió:
> >
> > > 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
>
> 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?

Yes.

If the table actually contains 1000 rows, the most likely outcome is
that the bitmaps would not be lossy and therefore no rechecking is
needed at all.  (Tuple bitmaps become lossy only if they have to store a
lot of tuples, in which case they forget the idea of storing each tuple,
and instead "compress" the representation to storing only the page
numbers where matching tuples are to be found).

Note however, that even if the bitmaps are not lossy, the visit to the
heap is still required, because the need to check for visibility.

--
Alvaro Herrera       Valdivia, Chile   ICBM: S 39º 49' 18.1", W 73º 13' 56.4"
"Industry suffers from the managerial dogma that for the sake of stability
and continuity, the company should be independent of the competence of
individual employees."                                      (E. Dijkstra)

pgsql-general by date:

Previous
From: "Josh Harrison"
Date:
Subject: Re: Recheck condition
Next
From: "Willy-Bas Loos"
Date:
Subject: Re: 1 cluster on several servers