Re: BUG #18978: Index does not work in aggregate function filter - Mailing list pgsql-bugs

From David G. Johnston
Subject Re: BUG #18978: Index does not work in aggregate function filter
Date
Msg-id CAKFQuwYOmxCjBeyAC1z0AS+Gt=vD_tMhnd10iHzezWxUBQpHig@mail.gmail.com
Whole thread Raw
In response to BUG #18978: Index does not work in aggregate function filter  (PG Bug reporting form <noreply@postgresql.org>)
List pgsql-bugs
On Thu, Jul 3, 2025 at 9:23 AM PG Bug reporting form <noreply@postgresql.org> wrote:
The following bug has been logged on the website:

Bug reference:      18978
Logged by:          Jinhui
Email address:      jinhui-lai@foxmail.com
PostgreSQL version: 17.5
Operating system:   ubuntu 22.04
Description:       


explain SELECT COUNT(c1) FILTER (WHERE c1<2) FROM t1;
 
No.  You just need to use a where clause when it is appropriate and a filter when it is appropriate.  A filter clause has no right imposing a restriction on what rows are selected for its level of query - other columns may very well need those rows.

David J.

pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #18978: Index does not work in aggregate function filter
Next
From: Gunnar Morling
Date:
Subject: Unexpected behavior when setting "idle_replication_slot_timeout"