On 2016/09/27 13:33, Ashutosh Bapat wrote:
I wrote:
>>>>>> ISTM that the use of the same RTI for subqueries in multi-levels in a
>>>>>> remote
>>>>>> SQL makes the SQL a bit difficult to read. How about using the
>>>>>> position
>>>>>> of
>>>>>> the join rel in join_rel_list, (more precisely, the position plus
>>>>>> list_length(root->parse->rtable)), instead?
I wrote:
>> The join rel is appended to the end of the list, so I was thinking to get
>> the position info by list_length during postgresGetForeignJoinPaths.
> That's true only when the paths are being added to a newly created
> joinrel. But that's not true always. We may add paths with different
> joining order to an existing joinrel, in which case list_length would
> not give its position. Am I missing something?
I think you are right, but postgresGetForeignJoinPaths only allows us to
add a foreign join path to a newly created joinrel. The reason is
because that routine skips all its work after the first call for that
joinrel, by checking to see if joinrel->fdw_private is not NULL. So, I
think it's reasonable to get the position by list_length in that routine.
Best regards,
Etsuro Fujita