On Sat, Oct 29, 2011 at 12:25:46AM -0700, Hitoshi Harada wrote: > I have a doubt here, on sharing connection for each server. What if > there are simultaneous scan on the same plan? Say, > > -> Nested Loop > -> Foreign Scan to table T1 on server A > -> Foreign Scan to table T2 on server A > > Okay, you are thinking about Foreign Join, so example above is too > simple. But it is always possible to execute such a query if foreign > scan nodes are separated far, isn't it? As far as I see from your > explanation, scan T1 and scan T2 share the same connection. Now join > node scans one row from left (T1) while asking rows from right (T2) > without fetching all the rows from left. If T2 requests to server A, > the connection's result (of T1) is discarded. Am I understand > correctly?
This would need to be factored in in the cost calculations. For remote servers there is an overhead per tuple transmitted. So in the above case it might actually be quicker to do the nested loop locally. To handle the parallel case you might need to materialise in the inner loop, that would avoid the double scan. Or we could fix the protocol so you can stream multiple queries at once. Actually, you can already do this is you use DECLARE CURSOR for all the queries upfront and then FETCH as needed. That way you can do it all over one connection. Have a nice day, -- Martijn van Oosterhout <klep...@svana.org> http://svana.org/kleptog/ > He who writes carelessly confesses thereby at the very outset that he does > not attach much importance to his own thoughts. -- Arthur Schopenhauer
Description: Digital signature