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