Re: Allowing join removals for more join types - Mailing list pgsql-hackers
From | David Rowley |
---|---|
Subject | Re: Allowing join removals for more join types |
Date | |
Msg-id | CAApHDvoTeUGH34PrWNHtQT_FABtU95FiNL-Sq6UXbsJXW09f0w@mail.gmail.com Whole thread Raw |
In response to | Re: Allowing join removals for more join types (Dilip kumar <dilip.kumar@huawei.com>) |
Responses |
Re: Allowing join removals for more join types
|
List | pgsql-hackers |
On 23 May 2014 12:43 David Rowley Wrote,
>I'm hitting a bit of a roadblock on point 1. Here's a snipped from my latest attempt:
> if (bms_membership(innerrel->relids) == BMS_SINGLETON)
> {
> int subqueryrelid = bms_singleton_member(innerrel->relids);
> RelOptInfo *subqueryrel = find_base_rel(innerrel->subroot, subqueryrelid);
>
> if (relation_has_unique_index_for(root, subqueryrel, clause_list, NIL, NIL))
> return true;
> }
>But it seems that innerrel->subroot is still NULL at this stage of planning and from what I can tell does not exist anywhere else yet and is not generated until make_one_rel() is called from query_planner()
>Am I missing something major here,or does this sound about right?
It’s true that, till this point of time we haven’t prepared the base relation list for the subquery, and that will be done from make_one_rel while generating the SUBQURY path list.
I can think of one solution but I think it will be messy…
We get the base relation info directly from subquery
Like currently in your patch (shown in below snippet) we are getting the distinct and groupby clause from sub Query, similarly we can get base relation info from (Query->jointree)
if (innerrel->rtekind == RTE_SUBQUERY)
{
Query *query = root->simple_rte_array[innerrelid]->subquery;
if (sortclause_is_unique_on_restrictinfo(query, clause_list, query->groupClause) ||
sortclause_is_unique_on_restrictinfo(query, clause_list, query->distinctClause))
return true;
}
Regards,
Dilip
pgsql-hackers by date: