Unstable path in index regress test query

From: Nikita Malakhov <hukutoc(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Unstable path in index regress test query
Date: 2026-01-23 18:00:11
Message-ID: CAN-LCVOgBms6==prC48io0kw_muQfYerEbiYxNivqRCcLgL0qw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hackers!

While doing some tests I've stumbled upon an unstable behavior of the query

explain
SELECT unique1 FROM tenk1
WHERE unique1 IN (1,42,7)
ORDER BY unique1;

from create_index regress test.

This test could randomly return any of 2 paths (below is sequential run,
clean latest master install, without server restart or any other queries
in-between):

postgres=# explain SELECT unique1 FROM tenk1
WHERE unique1 IN (1,42,7)
ORDER BY unique1;
QUERY PLAN
-------------------------------------------------------------------------------------
Sort (cost=310.65..311.02 rows=150 width=4)
Sort Key: unique1
-> Bitmap Heap Scan on tenk1 (cost=14.02..305.23 rows=150 width=4)
Recheck Cond: (unique1 = ANY ('{1,42,7}'::integer[]))
-> Bitmap Index Scan on tenk1_unique1 (cost=0.00..13.98 rows=150
width=0)
Index Cond: (unique1 = ANY ('{1,42,7}'::integer[]))
(6 rows)

postgres=# explain SELECT unique1 FROM tenk1
WHERE unique1 IN (1,42,7)
ORDER BY unique1;
QUERY PLAN
---------------------------------------------------------------------------------
Index Only Scan using tenk1_unique1 on tenk1 (cost=0.29..12.91 rows=3
width=4)
Index Cond: (unique1 = ANY ('{1,42,7}'::integer[]))
(2 rows)

The strange thing is that paths are returned quite randomly, but the first
more often than the second.
Is it a bug? Or some feature?

You could check the full log in attach.

Thanks!

--
Regards,
Nikita Malakhov
Postgres Professional
The Russian Postgres Company
https://postgrespro.ru/

Attachment Content-Type Size
regress_create_index.out application/octet-stream 4.8 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2026-01-23 18:11:19 Re: Unstable path in index regress test query
Previous Message Jacob Champion 2026-01-23 17:50:40 Re: Time to drop RADIUS support?