Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ksEwF-0008K9-Ru for pgsql-general@arkaria.postgresql.org; Thu, 24 Dec 2020 00:57:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ksEwE-0006tC-QE for pgsql-general@arkaria.postgresql.org; Thu, 24 Dec 2020 00:57:06 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ksEwE-0006t5-Ii for pgsql-general@lists.postgresql.org; Thu, 24 Dec 2020 00:57:06 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ksEwC-0000mi-9Q for pgsql-general@lists.postgresql.org; Thu, 24 Dec 2020 00:57:05 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 0BO0v28w748834; Wed, 23 Dec 2020 19:57:02 -0500 From: Tom Lane To: Augusto Callejas cc: pgsql-general@lists.postgresql.org Subject: Re: bitmap heap scan exact/lossy blocks and row removal In-reply-to: References: Comments: In-reply-to Augusto Callejas message dated "Wed, 23 Dec 2020 13:51:46 -1000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <748832.1608771422.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 23 Dec 2020 19:57:02 -0500 Message-ID: <748833.1608771422@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Augusto Callejas 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 understandi= ng > (mainly from > https://paquier.xyz/postgresql-2/postgres-9-4-feature-highlight-lossyexa= ct-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