On 2016/09/26 16:30, Etsuro Fujita wrote:
> On 2016/09/13 14:17, Ashutosh Bapat wrote:
>> It won't remain minimal as the number of paths created increases,
>> increasing the number of times a query is deparsed. We deparse query
>> every time time we cost a path for a relation with use_remote_estimates
>> true. As we try to push down more and more stuff, we will create more
>> paths and deparse the query more time.
>> Also, that makes the interface better. Right now, in your patch, you
>> have changed the order of deparsing in the existing code, so that the
>> aliases are registered while deparsing FROM clause and before any Var
>> nodes are deparsed. If we create aliases at the time of path creation,
>> only once in GetForeignJoinPaths or GetForeignPaths as appropriate, that
>> would require less code churn and would save some CPU cycles as well.
> Agreed. Will fix.
Done. Attached is an updated version of the patch.
I didn't create aliases at anytime. Instead, I added a logic to get
info about the alias to a given expression from reltarget->exprs for
relations in a given join tree. See isSubqueryExpr and
getSubselectAliasInfo.
As proposed by you, the patch differentiates between a base relation
alias and a subquery alias by using different prefixes "r" and "s",
respectively. Also, subquery aliases are indexed by RTI for baserels
and the position in join_rel_list + the length of rtable for joinrels,
as proposed upthread.
Best regards,
Etsuro Fujita