Re: Index Searches higher than expected for skip scan - Mailing list pgsql-performance

From Peter Geoghegan
Subject Re: Index Searches higher than expected for skip scan
Date
Msg-id CAH2-Wz=x9RTnDJUeN7yq1TftnH00L5jGtAtnB6L6i87b8Yy1fA@mail.gmail.com
Whole thread Raw
In response to Re: Index Searches higher than expected for skip scan  (Michael Christofides <michael@pgmustard.com>)
List pgsql-performance
On Fri, Nov 7, 2025 at 6:16 AM Michael Christofides
<michael@pgmustard.com> wrote:
> Thank you for the incredibly helpful (and fast) replies Peter.

You're welcome.

> Nice idea. Once it sunk in, I realised I could try the explicit "AND boolean_field IN (true, false)" and got it down
to2 index searches: 
>
> EXPLAIN (ANALYZE, BUFFERS, VERBOSE, SETTINGS)
> SELECT boolean_field FROM example WHERE integer_field = 5432 AND boolean_field IN (true, false);

That's using the Postgres 17 work. You could also write the query as
"SELECT boolean_field FROM example WHERE integer_field = 5432 AND
boolean_field BETWEEN false AND true" and get 2 index searches. That
variant uses what I've called "range skip scan", which is new in
Postgres 18.

--
Peter Geoghegan



pgsql-performance by date:

Previous
From: Michael Christofides
Date:
Subject: Re: Index Searches higher than expected for skip scan
Next
From: Vitalii Tymchyshyn
Date:
Subject: Multicolumn index scan efficiency