Re: Pathify RHS unique-ification for semijoin planning
От | wenhui qiu |
---|---|
Тема | Re: Pathify RHS unique-ification for semijoin planning |
Дата | |
Msg-id | CAGjGUAKhb1XaGeKrbZpZM7MiKcVU3wiBDEi9=WEGFAS-gTRXpg@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Pathify RHS unique-ification for semijoin planning (Richard Guo <guofenglinux@gmail.com>) |
Ответы |
Re: Pathify RHS unique-ification for semijoin planning
|
Список | 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))
+
+ * 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);
}
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@gmail.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
В списке pgsql-hackers по дате отправления: