Re: BUG #15984: order of where in() query affects query planer

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: easteregg(at)verfriemelt(dot)org
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #15984: order of where in() query affects query planer
Date: 2019-08-29 22:16:45
Message-ID: 7528.1567117005@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

PG Bug reporting form <noreply(at)postgresql(dot)org> writes:
> i have a partial index like in the following example and when reorder the
> elements of the in() statement,
> i get sometimes a bitmap indexscan instead of the expected index only scan.
> if i remove an element, i still get the index only,
> but with the wrong order, i get a bitmap heap scan. is this expected?

FWIW, I get the same plan shape with either order of the IN elements.

However, your example is probably going to be subject to plan instability
because

(1) you used vacuum full not plain vacuum. That doesn't leave the table
in the all-visible condition that would favor an index-only scan.

(2) you didn't analyze the table. At some point, autovacuum will come
along and rectify that oversight, likely causing the plan choice to
change underneath you.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message easteregg 2019-08-30 06:54:03 Re: BUG #15984: order of where in() query affects query planer
Previous Message PG Bug reporting form 2019-08-29 15:48:46 BUG #15984: order of where in() query affects query planer