Re: bitmap heap scan exact/lossy blocks and row removal - Mailing list pgsql-general

From Tom Lane
Subject Re: bitmap heap scan exact/lossy blocks and row removal
Date
Msg-id 748833.1608771422@sss.pgh.pa.us
Whole thread Raw
In response to bitmap heap scan exact/lossy blocks and row removal  (Augusto Callejas <acallejas@instructure.com>)
List pgsql-general
Augusto Callejas <acallejas@instructure.com> writes:
> I created a GIN index on the following relation and ran an EXPLAIN query on
> a query, and noticed that despite all heap blocks being exact, that the
> outermost bitmap heap scan removed 62 rows after recheck. My understanding
> (mainly from
> https://paquier.xyz/postgresql-2/postgres-9-4-feature-highlight-lossyexact-pages-for-bitmap-heap-scan)
> is that if there are only exact pages, then there are only tuples in the
> bitmap, so I wouldn't expect to see rows being removed by the recheck.

"exact" in that context just means that the bitmap mechanism didn't
forget any details about which row TIDs were returned by the index.
But the index itself could be lossy, ie it can return some rows that only
*might* match the query.  The recheck mechanism exists mainly for that
purpose --- backstopping a lossy bitmap was something we tacked on later.

An example here is that a trigram index will only tell you which rows
contain the same trigrams that the query string does.  Whether they are
in the right order has to be verified by a recheck of the original query
operator applied to the real data.

            regards, tom lane



pgsql-general by date:

Previous
From: Augusto Callejas
Date:
Subject: bitmap heap scan exact/lossy blocks and row removal
Next
From: Shantanu Shekhar
Date:
Subject: Range search on primary key does not use index scan