| From: | Richard Guo <guofenglinux(at)gmail(dot)com> |
|---|---|
| To: | wenhui qiu <qiuwenhuifx(at)gmail(dot)com> |
| Cc: | Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Fix HAVING-to-WHERE pushdown with nondeterministic collations |
| Date: | 2026-04-02 10:11:07 |
| Message-ID: | CAMbWs4-B1qNNf5oATbeqrUYwnTShz9=mdDh2=bcq1QREBYv0wg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Wed, Apr 1, 2026 at 11:19 AM wenhui qiu <qiuwenhuifx(at)gmail(dot)com> wrote:
> > + vars = pull_var_clause(node, PVC_RECURSE_PLACEHOLDERS);
> > +
> > + foreach_node(Var, var, vars)
> > + {
> > + if (var->varno == *group_rtindex &&
> > + OidIsValid(var->varcollid) &&
> > + var->varcollid != inputcollid &&
> > + !get_collation_isdeterministic(var->varcollid))
> > + {
> > + list_free(vars);
> > + return true;
> > + }
> > + }
> > +
> > + list_free(vars);
> This might be overthinking, but I wonder if calling pull_var_clause() at each walker step could introduce some overhead due to repeated subtree scans
That's a good point, but I doubt that it'd be an issue in practice.
HAVING clauses are typically very small expressions. Even in unusual
queries, the clause size is bounded by what a human writes, which is
negligible compared to the work the planner does elsewhere.
Maybe we can avoid this by calling pull_var_clause once at the top of
each clause and reusing that var list at every node. But that can
introduce false positives. The pre-pulled list contains all GROUP
Vars from the entire clause, but a given operator node only acts on
the vars in its own subtree.
- Richard
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Ashutosh Sharma | 2026-04-02 10:24:26 | Re: synchronized_standby_slots behavior inconsistent with quorum-based synchronous replication |
| Previous Message | Imran Zaheer | 2026-04-02 09:49:51 | Silence -Wmaybe-uninitialized warnings |