Re: Some optimizations for COALESCE expressions during constant folding - Mailing list pgsql-hackers

From David Rowley
Subject Re: Some optimizations for COALESCE expressions during constant folding
Date
Msg-id CAApHDvpgz=4XY_nm2rhJvrC06Zfti9S00mjX8V+rgoPsSW_BZQ@mail.gmail.com
Whole thread Raw
In response to Some optimizations for COALESCE expressions during constant folding  (Richard Guo <guofenglinux@gmail.com>)
Responses Re: Some optimizations for COALESCE expressions during constant folding
List pgsql-hackers
On Tue, 25 Nov 2025 at 23:51, Richard Guo <guofenglinux@gmail.com> wrote:
> (I'm wondering whether it'd be better to consolidate the
> non-null check for Const, Var, and CoalesceExpr into one helper
> function to simplify the code in eval_const_expressions.)

uhh, of course it is. That's what I did in [1] for Consts and expand
expr_is_nonnullable() to support COALESCE exprs then modify
eval_const_expressions_mutator() to use that rather than using
var_is_nonnullable(). That way we'll not need to modify the constant
folding code every time we think of something new that we can prove
can't be NULL.

David

[1]
https://www.postgresql.org/message-id/attachment/184166/v3-0001-Have-the-planner-replace-COUNT-ANY-with-COUNT-whe.patch



pgsql-hackers by date:

Previous
From: Dagfinn Ilmari Mannsåker
Date:
Subject: Re: Some optimizations for COALESCE expressions during constant folding
Next
From: 河田達也
Date:
Subject: Re: [PATCH] Add memory usage reporting to VACUUM VERBOSE