Re: [GENERAL] Trouble: subquery doesn't terminate

Поиск
Список
Период
Сортировка
От Herbert Liechti
Тема Re: [GENERAL] Trouble: subquery doesn't terminate
Дата
Msg-id 388EA1DD.6685C433@thinx.ch
обсуждение исходный текст
Ответ на Trouble: subquery doesn't terminate  (mwilson@the-wire.com (Mel Wilson))
Список pgsql-general
Mel Wilson wrote:
>
>    Trouble:  I'm running CGI perl routines from Apache (without
> mod_perl) to query a small database.  This query ran over 6 minutes
> before Apache timed out and dropped the pipe:
>
> $result = $conn->exec(qq/
>         SELECT t.tune_id, t.title
>           FROM tune t
>          WHERE t.tune_id IN
>            (SELECT c.tune_id FROM composer c WHERE c.person_id = $person_id)
> /);

The IN Clause is known to be very slow. Try to use the EXISTS clause
instead. I had the same problem. After changing to the EXISTS
variant my performance troubles went away.
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Herbert Liechti                     E-Mail: Herbert.Liechti@thinx.ch
ThinX networked business services        Stahlrain 10, CH-5200 Brugg
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

Предыдущее
От: Chairudin Sentosa Harjo
Дата:
Сообщение: Re: [GENERAL] Query time is too long for netscape
Следующее
От: "DSDeurne Automatisering, Wim Aarts"
Дата:
Сообщение: Re: [GENERAL] Re: server hardware recommendations