Unstable path in index regress test query - Mailing list pgsql-hackers

From Nikita Malakhov
Subject Unstable path in index regress test query
Date
Msg-id CAN-LCVOgBms6==prC48io0kw_muQfYerEbiYxNivqRCcLgL0qw@mail.gmail.com
Whole thread Raw
Responses Re: Unstable path in index regress test query
List 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
Attachment

pgsql-hackers by date:

Previous
From: Jacob Champion
Date:
Subject: Re: Time to drop RADIUS support?
Next
From: Tom Lane
Date:
Subject: Re: Unstable path in index regress test query