Re: 'fake' join and performance ?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: 'fake' join and performance ?
Дата
Msg-id 24033.1035308365@sss.pgh.pa.us
обсуждение исходный текст
Ответ на 'fake' join and performance ?  ("Peter Galbavy" <peter.galbavy@knowtion.net>)
Список pgsql-sql
"Peter Galbavy" <peter.galbavy@knowtion.net> writes:
> photos=# select * from metadata m, images i WHERE m.name = 'Make' and
> m.value = 'Canon' limit 10;

> Er, what's that nested loop. I *know* I have shot myself in the foot
> somehow,

Yeah, you didn't restrict the reference to images at all.

> but my initial reaction was that the optimiser should just make the
> 'fake' (i.e. unreferenced) reference to another table go away...

That would be in violation of the SQL spec.  The query is defined to
return each join row from the cross product of the FROM tables that
meets the condition of the WHERE clause.  As you wrote the query, each
metadata row that meets the WHERE clause will be returned exactly as
many times as there are rows in the images table.  There is no such
thing as an "unreferenced" FROM entry as far as SQL is concerned.
        regards, tom lane


В списке pgsql-sql по дате отправления:

Предыдущее
От: Stephan Szabo
Дата:
Сообщение: Re: 'fake' join and performance ?
Следующее
От: "Peter Galbavy"
Дата:
Сообщение: Re: 'fake' join and performance ?