Re: Index Searches higher than expected for skip scan

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: Michael Christofides <michael(at)pgmustard(dot)com>
Cc: pgsql-performance(at)lists(dot)postgresql(dot)org
Subject: Re: Index Searches higher than expected for skip scan
Date: 2025-11-07 15:00:49
Message-ID: CAH2-Wz=x9RTnDJUeN7yq1TftnH00L5jGtAtnB6L6i87b8Yy1fA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Fri, Nov 7, 2025 at 6:16 AM Michael Christofides
<michael(at)pgmustard(dot)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 to 2 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

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Vitalii Tymchyshyn 2025-11-10 02:44:25 Multicolumn index scan efficiency
Previous Message Michael Christofides 2025-11-07 11:16:34 Re: Index Searches higher than expected for skip scan