Re: NOT IN subquery optimization
От | Andrey Lepikhov |
---|---|
Тема | Re: NOT IN subquery optimization |
Дата | |
Msg-id | ef790c4a-6186-4591-7f19-9c2c87b6fd2a@postgrespro.ru обсуждение исходный текст |
Ответ на | Re: NOT IN subquery optimization ("Li, Zheng" <zhelli@amazon.com>) |
Список | pgsql-hackers |
On 1/7/20 12:34 AM, Li, Zheng wrote: > Hi Andrey, > > Thanks for the comment! > > The unimproved cases you mentioned all fall into the category “correlated subquery”. This category is explicitly disallowedby existing code to convert to join in convert_ANY_sublink_to_join: > /* > * The sub-select must not refer to any Vars of the parent query. (Vars of > * higher levels should be okay, though.) > */ > if (contain_vars_of_level((Node *) subselect, 1)) > return NULL; > > I think this is also the reason why hashed subplan is not used for such subqueries. > > It's probably not always safe to convert a correlated subquery to join. We need to find out/prove when it’s safe/unsafeto convert such ANY subquery if we were to do so. > Maybe this part of code contains logical error? You optimize only the special case of the "NOT IN" expression, equal to NOT EXISTS. The convert_EXISTS_sublink_to_join() routine can contain vars of the parent query. May be you give an trivial example for this problem? -- Andrey Lepikhov Postgres Professional https://postgrespro.com The Russian Postgres Company
В списке pgsql-hackers по дате отправления: