pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
To: William Bernbaum <wbernbaum@dwdev.com>
Cc: guofenglinux@gmail.com <guofenglinux@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org <pgsql-hackers@lists.postgresql.org>
Subject: Re: Skipping NULL keys when uniqueifying a semijoin's RHS
Date: Wed, 26 Aug 2026 13:46:01 +0100
Message-ID: <878q5tyrqu.fsf@wibble.ilmari.org> (raw)
In-Reply-To: <PH0PR18MB44436F7F588A50C0EB92383DA6AF2@PH0PR18MB4443.namprd18.prod.outlook.com>
References: <PH0PR18MB44436F7F588A50C0EB92383DA6AF2@PH0PR18MB4443.namprd18.prod.outlook.com>

William Bernbaum <wbernbaum@dwdev.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






view thread (5+ messages)  latest in thread

Message-ID: <878q5tyrqu.fsf@wibble.ilmari.org>
Permalink:  ../878q5tyrqu.fsf@wibble.ilmari.org/
Also on:    postgresql.org/message-id/878q5tyrqu.fsf@wibble.ilmari.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: ilmari@ilmari.org, wbernbaum@dwdev.com, guofenglinux@gmail.com
  Subject: Re: Skipping NULL keys when uniqueifying a semijoin's RHS
  In-Reply-To: <878q5tyrqu.fsf@wibble.ilmari.org>
  References: <PH0PR18MB44436F7F588A50C0EB92383DA6AF2@PH0PR18MB4443.namprd18.prod.outlook.com> <878q5tyrqu.fsf@wibble.ilmari.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox