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 1oaihc-0008LY-5V for pgsql-bugs@arkaria.postgresql.org; Tue, 20 Sep 2022 19:14:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oaihb-0004nF-1b for pgsql-bugs@arkaria.postgresql.org; Tue, 20 Sep 2022 19:14:39 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oaiha-0004n6-Pv for pgsql-bugs@lists.postgresql.org; Tue, 20 Sep 2022 19:14:38 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oaihY-0003th-An for pgsql-bugs@lists.postgresql.org; Tue, 20 Sep 2022 19:14:38 +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 28KJEYo3739954; Tue, 20 Sep 2022 15:14:34 -0400 From: Tom Lane To: Jeff Janes cc: sindysenorita@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17618: unnecessary filter column <> text even after adding index In-reply-to: References: <17618-7a2240bfaa7e84ae@postgresql.org> <349136.1663601052@sss.pgh.pa.us> Comments: In-reply-to Jeff Janes message dated "Tue, 20 Sep 2022 13:12:03 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <739952.1663701274.1@sss.pgh.pa.us> Date: Tue, 20 Sep 2022 15:14:34 -0400 Message-ID: <739953.1663701274@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Jeff Janes writes: > You are describing a Recheck, but attributing its properties to a Filter. You're right of course, momentary brain fade on my part. > I don't know about being a bug, but it is at least a mild mal-feature that > boolean index columns/expressions can't be dealt with better, and have to > be handed in a filter rather than in a recheck. Yeah ... looking at create_bitmap_scan_plan, I see that it does this: /* * When dealing with special operators, we will at this point have * duplicate clauses in qpqual and bitmapqualorig. We may as well drop * 'em from bitmapqualorig, since there's no point in making the tests * twice. */ bitmapqualorig = list_difference_ptr(bitmapqualorig, qpqual); I wonder if that isn't backwards, ie we should prefer to put duplicates in bitmapqualorig (the recheck condition) instead of qpqual (the filter). If my head is screwed on correctly today, that should allow us to skip checking the condition much of the time, and the skip would be safe if the index is correctly asserting that no recheck is needed. regards, tom lane