Re: BUG #18978: Index does not work in aggregate function filter

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: jinhui-lai(at)foxmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18978: Index does not work in aggregate function filter
Date: 2025-07-03 16:36:29
Message-ID: CAKFQuwYOmxCjBeyAC1z0AS+Gt=vD_tMhnd10iHzezWxUBQpHig@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, Jul 3, 2025 at 9:23 AM PG Bug reporting form <noreply(at)postgresql(dot)org>
wrote:

> The following bug has been logged on the website:
>
> Bug reference: 18978
> Logged by: Jinhui
> Email address: jinhui-lai(at)foxmail(dot)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.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2025-07-03 17:48:14 Re: BUG #18970: Atempt to alter type of table column used in row type with check leads to assertion failure
Previous Message PG Bug reporting form 2025-07-03 16:13:59 BUG #18978: Index does not work in aggregate function filter