Re: Recursive optimization of IN subqueries
От | Tom Lane |
---|---|
Тема | Re: Recursive optimization of IN subqueries |
Дата | |
Msg-id | 27924.1074880349@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: Recursive optimization of IN subqueries (Dennis Haney <davh@diku.dk>) |
Список | pgsql-general |
Dennis Haney <davh@diku.dk> writes: > I saw it as though convert_IN_to_join rewrote the query from > select a.* from tenk1 a where a.unique1 in > (select c.thousand from tenk1 c where c.hundred = 99); > to > select a.* from tenk1 a, tenk1 c where a.unique1 = c.thousand AND > c.hundred = 99; > But after looking at it, I've reached the conclusion that the rewrite is > to this instead: > select a.* from tenk1 a, (select d.thousand from tenk1 d where > d.hundred = 99) as c where a.unique1 = c.thousand; Right. We do that, and then subsequently pull_up_subqueries transforms it to the other representation. The reason for this two-step approach is that the intermediate form is still a useful improvement if the subquery can't be pulled up for some reason (e.g., it's got grouping). > except the subselect is added as a range table entry instead of a > subselect in the from-list (not that I understand this particular part, > do you mind explaining?). Same thing. Every entry in the from-list will have both an RTE and an entry in the join tree. This representation is partly historical (before we had outer joins, there was only the range table and no join tree at all), but it is convenient for many purposes. regards, tom lane PS: this is a bit off-topic for pgsql-general, please pursue it on -hackers if you have more questions.
В списке pgsql-general по дате отправления: