Re: Removing unneeded self joins
От | Zhihong Yu |
---|---|
Тема | Re: Removing unneeded self joins |
Дата | |
Msg-id | CALNJ-vTaTkeY3yc=r8MR7XuqvGUAytP=NdFTtOq-Lh1otKmhNQ@mail.gmail.com обсуждение исходный текст |
Ответ на | Removing unneeded self joins (Alexander Kuzmenkov <a.kuzmenkov@postgrespro.ru>) |
Список | pgsql-hackers |
Hi,
w.r.t. v33-0001-Remove-self-joins.patch :
removes inner join of plane table -> removes inner join of plain table
in an query plan -> in a query plan
+ * Used as the relation_has_unique_index_for,
Since relation_has_unique_index_for() becomes a wrapper of relation_has_unique_index_ext, the above sentence doesn't make much sense. I think you can drop this part.
but if extra_clauses doesn't NULL -> If extra_clauses isn't NULL
+ is_req_equal =
+ (rinfo->required_relids == rinfo->clause_relids) ? true : false;
+ (rinfo->required_relids == rinfo->clause_relids) ? true : false;
The above can be simplified to:
is_req_equal = rinfo->required_relids == rinfo->clause_relids;
+ ListCell *otherCell;
otherCell should be initialized to NULL.
+ if (bms_is_member(k, info->syn_lefthand) &&
+ !bms_is_member(r, info->syn_lefthand))
+ jinfo_check = false;
+ else if (bms_is_member(k, info->syn_righthand) &&
+ !bms_is_member(r, info->syn_righthand))
+ jinfo_check = false;
+ else if (bms_is_member(r, info->syn_lefthand) &&
+ !bms_is_member(k, info->syn_lefthand))
+ jinfo_check = false;
+ !bms_is_member(r, info->syn_lefthand))
+ jinfo_check = false;
+ else if (bms_is_member(k, info->syn_righthand) &&
+ !bms_is_member(r, info->syn_righthand))
+ jinfo_check = false;
+ else if (bms_is_member(r, info->syn_lefthand) &&
+ !bms_is_member(k, info->syn_lefthand))
+ jinfo_check = false;
I think the above code can be simplified:
If bms_is_member(k, info->syn_lefthand) ^ bms_is_member(r, info->syn_lefthand) is true, jinfo_check is false.
If bms_is_member(k, info->syn_righthand) ^ bms_is_member(r, info->syn_righthand) is true, jinfo_check is false.
Otherwise jinfo_check is true.
Cheers
В списке pgsql-hackers по дате отправления: