Re: Skipping NULL keys when uniqueifying a semijoin's RHS

From: Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org>
To: William Bernbaum <wbernbaum(at)dwdev(dot)com>
Cc: "guofenglinux(at)gmail(dot)com" <guofenglinux(at)gmail(dot)com>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Skipping NULL keys when uniqueifying a semijoin's RHS
Date: 2026-08-26 12:46:01
Message-ID: 878q5tyrqu.fsf@wibble.ilmari.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

William Bernbaum <wbernbaum(at)dwdev(dot)com> writes:

> The attached patch adds a pass, add_semijoin_not_null_quals(),
> which runs before set_base_rel_sizes(), that walks
> root->join_info_list, and, for each semijoin whose
> righthand keys can be unique-ified, pushes an IS NOT NULL
> restriction down onto the key.

I'm by no means an expert on the planner, but the idea seems sound to
me, and on the surface the change looks sensible. I have just a couple
of code nitpicks:

> + ListCell *lc;
> +
> + foreach(lc, root->join_info_list)
> + {
> + SpecialJoinInfo *sjinfo = (SpecialJoinInfo *) lfirst(lc);

This should be foreach_node(SpecialJoinInfo, sjinfo, root->join_info_list).

> + ListCell *lc2;
[...]
> + foreach(lc2, sjinfo->semi_rhs_exprs)
> + {
> + Expr *expr = (Expr *) lfirst(lc2);

And this should be foreach_node(Expr, expr, sjinfo->semi_rhs_exprs).

- ilmari

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message vignesh C 2026-08-26 12:52:03 Re: Proposal: Conflict log history table for Logical Replication
Previous Message Ayush Tiwari 2026-08-26 12:44:34 Re: Error handling in after-startup shmem requests