pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #17944: Partial index on boolean field is not picked when using = while the index is created with is
2+ messages / 2 participants
[nested] [flat]

* BUG #17944: Partial index on boolean field is not picked when using = while the index is created with is
@ 2023-05-25 14:04  PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 1 reply; 2+ messages in thread

From: PG Bug reporting form @ 2023-05-25 14:04 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: ajeesh2705@gmail.com

The following bug has been logged on the website:

Bug reference:      17944
Logged by:          Ajeesh Sasidharan
Email address:      ajeesh2705@gmail.com
PostgreSQL version: 13.8
Operating system:   Linux
Description:        

I have recently created a partial index on tables like following 

create index unprocessed_order_index
    on order (creation_date) where processed is false;

When I am querying the table using processed = false like below, the index
is not used 

SELECT count(*) from order where processed = false and creation_date <
now()

but the index is used while querying using processed is false

SELECT count(*) from order where processed is false and creation_date <
now()

I was expecting to treat both = and is same, or am I wrong



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #17944: Partial index on boolean field is not picked when using = while the index is created with is
@ 2023-05-25 19:20  Tom Lane <tgl@sss.pgh.pa.us>
  parent: PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2023-05-25 19:20 UTC (permalink / raw)
  To: ajeesh2705@gmail.com; +Cc: pgsql-bugs@lists.postgresql.org

PG Bug reporting form <noreply@postgresql.org> writes:
> I have recently created a partial index on tables like following 

> create index unprocessed_order_index
>     on order (creation_date) where processed is false;

> When I am querying the table using processed = false like below, the index
> is not used 

> I was expecting to treat both = and is same, or am I wrong

IS and = are not the same.  You could argue that they have the same effect
in this particular case, but there's no logic in the planner that would
deduce that.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2023-05-25 19:20 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-05-25 14:04 BUG #17944: Partial index on boolean field is not picked when using = while the index is created with is PG Bug reporting form <noreply@postgresql.org>
2023-05-25 19:20 ` Tom Lane <tgl@sss.pgh.pa.us>

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