pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomas Vondra <tomas.vondra@enterprisedb.com>
To: udv.mail@gmail.com, pgsql-bugs@lists.postgresql.org, PG Bug reporting form <noreply@postgresql.org>
Subject: Re: BUG #17295: Different query plan with Index Only Scan and Bitmap Index Scan.
Date: Mon, 22 Nov 2021 00:37:32 +0100
Message-ID: <aee23e3a-19dc-95da-34a3-d34e070e4294@enterprisedb.com> (raw)
In-Reply-To: <17295-82a33e30e35c0cd5@postgresql.org>
References: <17295-82a33e30e35c0cd5@postgresql.org>

Hi,

I'm not really sure which part you condides a bug? We simply don't 
translate between IN() and OR-ed conditions, and there may be some 
costing differences. So we may generate different plans, and the switch 
between index scan and bitmap index scan may happen at different points.

On 11/20/21 17:52, PG Bug reporting form wrote:
> 
> EXPLAIN SELECT * FROM t WHERE a IN (142,147,153,199);
> -- Bitmap Heap Scan on t  (cost=3739.74..50987.74 rows=200000 width=8)
> |
> --   Recheck Cond: (a = ANY ('{142,147,153,199}'::integer[]))
> |
> --   ->  Bitmap Index Scan on t_i  (cost=0.00..3689.74 rows=200000
> width=0)|
> --         Index Cond: (a = ANY ('{142,147,153,199}'::integer[]))
> |

This is rather strange, though. Why would this have estimate 200000? The 
other query has estimate 4, so it can't be because of missing stats etc. 
Or why would it fix after several minutes?


regards

-- 
Tomas Vondra
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company





view thread (2+ messages)

Message-ID: <aee23e3a-19dc-95da-34a3-d34e070e4294@enterprisedb.com>
Permalink:  ../aee23e3a-19dc-95da-34a3-d34e070e4294@enterprisedb.com/
Also on:    postgresql.org/message-id/aee23e3a-19dc-95da-34a3-d34e070e4294@enterprisedb.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tomas.vondra@enterprisedb.com, noreply@postgresql.org
  Subject: Re: BUG #17295: Different query plan with Index Only Scan and Bitmap Index Scan.
  In-Reply-To: <aee23e3a-19dc-95da-34a3-d34e070e4294@enterprisedb.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox