Re: Have the planner convert COUNT(1) / COUNT(not_null_col) to COUNT(*)

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Corey Huinker <corey(dot)huinker(at)gmail(dot)com>
Cc: PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Have the planner convert COUNT(1) / COUNT(not_null_col) to COUNT(*)
Date: 2025-11-03 22:49:15
Message-ID: CAApHDvpPCv==BVhrar++mG3K6h-vgoDxfDtde6Zhy2F5O8Ex9w@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, 1 Nov 2025 at 14:19, Corey Huinker <corey(dot)huinker(at)gmail(dot)com> wrote:
>>
>> which might be a more realistic thing if the query without the WHERE
>> clause was part of a VIEW. However, we don't currently have any
>> infrastructure to detect when a column *is* NULL. There's only the
>> opposite with expr_is_nonnullable() or var_is_nonnullable().
>
> But we'd still catch NULL constants, yes?

Yes. It could. I've left that part of the patch #ifdef'd out. I wasn't
planning on using it. I just left it there as an example for if
someone wanted to test it.

> The change is a big win for clarity. Applies clean. Passes.

Thanks for checking.

David

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Noah Misch 2025-11-03 22:52:05 Re: Issues with ON CONFLICT UPDATE and REINDEX CONCURRENTLY
Previous Message David Rowley 2025-11-03 22:47:08 Re: Have the planner convert COUNT(1) / COUNT(not_null_col) to COUNT(*)