From: | wenhui qiu <qiuwenhuifx(at)gmail(dot)com> |
---|---|
To: | Richard Guo <guofenglinux(at)gmail(dot)com> |
Cc: | Alexandra Wang <alexandra(dot)wang(dot)oss(at)gmail(dot)com>, Álvaro Herrera <alvherre(at)kurilemu(dot)de>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andy Fan <zhihuifan1213(at)163(dot)com> |
Subject: | Re: Pathify RHS unique-ification for semijoin planning |
Date: | 2025-08-07 09:04:41 |
Message-ID: | CAGjGUAKhb1XaGeKrbZpZM7MiKcVU3wiBDEi9=WEGFAS-gTRXpg@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
HI Richard Guo
+/*
+ * Is given relation unique-ified?
+ *
+ * When the nominal jointype is JOIN_INNER, sjinfo->jointype is JOIN_SEMI,
and
+ * the given rel is exactly the RHS of the semijoin, it indicates that the
rel
+ * has been unique-ified.
+ */
+#define IS_UNIQUEIFIED_REL(rel, sjinfo, nominal_jointype) \
+ ((nominal_jointype) == JOIN_INNER && (sjinfo)->jointype == JOIN_SEMI && \
+ bms_equal((sjinfo)->syn_righthand, (rel)->relids))
+
In light of this commit (
https://github.com/postgres/postgres/commit/e035863c9a04beeecc254c3bfe48dab58e389e10)
I also recommend changing the macro to a static inline function. Macros are
harder to debug and lack type safety.
static inline bool
is_uniqueified_rel(RelOptInfo *rel, SpecialJoinInfo *sjinfo, JoinType
nominal_jointype)
{
return nominal_jointype == JOIN_INNER &&
sjinfo->jointype == JOIN_SEMI &&
bms_equal(sjinfo->syn_righthand, rel->relids);
}
Thanks
On Mon, Aug 4, 2025 at 10:08 AM Richard Guo <guofenglinux(at)gmail(dot)com> wrote:
> The v5 patch does not apply anymore, and here is a new rebase. There
> are two main changes in v6:
>
> * I choose to use the check I proposed earlier to determine whether a
> relation has been unique-ified in costsize.c.
>
> * Now that the only call to relation_has_unique_index_for() that
> supplied an exprlist and oprlist has been removed, the loop handling
> those lists is effectively dead code. 0002 removes that loop and
> simplifies the function accordingly.
>
> Thanks
> Richard
>
From | Date | Subject | |
---|---|---|---|
Next Message | Tomas Vondra | 2025-08-07 09:24:18 | Re: Adding basic NUMA awareness |
Previous Message | Jim Jones | 2025-08-07 08:41:24 | Re: XMLDocument (SQL/XML X030) |