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: regress_create_index.out
Description: Binary data

Reply via email to