Re: slow query

Поиск
Список
Период
Сортировка
От Josh Berkus
Тема Re: slow query
Дата
Msg-id 200302231347.58960.josh@agliodbs.com
обсуждение исходный текст
Ответ на Re: slow query  (Ryan Bradetich <rbradetich@uswest.net>)
Ответы Re: slow query
Список pgsql-performance
Ryan,

> > The above should use an EXISTS clause, not IN, unless you are absolutely
> > sure that the subquery will never return more than 12 rows.
>
> I am assuming you said this because EXISTS is faster for > 12 rows?
> Interesting :)

That's my rule of thumb, *NOT* any kind of relational-calculus-based truth.

Basically, one should only use IN for a subquery when one is *absolutely* sure
that the subquery will only return a handful of records, *and* the subquery
doesn't have to do an complex work like aggregating or custom function
evaluation.

You're safer using EXISTS for all subqueries, really.

--
Josh Berkus
Aglio Database Solutions
San Francisco

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

Предыдущее
От: Ryan Bradetich
Дата:
Сообщение: Re: slow query
Следующее
От: Tom Lane
Дата:
Сообщение: Re: slow query