Re: Possible bug in planner (or planner not enough wise in some cases)

Поиск
Список
Период
Сортировка
От Jim Nasby
Тема Re: Possible bug in planner (or planner not enough wise in some cases)
Дата
Msg-id 256DACC7-6168-4615-BA7A-354BE59331DF@nasby.net
обсуждение исходный текст
Ответ на Re: Possible bug in planner (or planner not enough wise in some cases)  ("Boguk Maxim" <astar@rambler-co.ru>)
Список pgsql-admin
On Sep 20, 2006, at 5:32 AM, Boguk Maxim wrote:

> Hm i have no idea how to rewrite 'OR' conditions with subqueries as
> joins
> (exept using 'UNION' as writen end of my message)
> Are you sure it is possible?
>
> WHERE
> (parent_id IN (SELECT tt.id FROM el_comment as tt WHERE
> tt.user_id=112 AND tt.status=1))
> OR
> (text_id IN (SELECT el_text.id FROM el_text WHERE
> el_text.user_id=112))
>>> somedb=# EXPLAIN ANALYZE SELECT count(*) FROM el_comment
>> WHERE ((parent_id IN (SELECT tt.id FROM el_comment as tt
>> WHERE tt.user_id = 112 AND tt.status=1)) OR (text_id IN
>> (SELECT el_text.id FROM el_text WHERE el_text.user_id =
>> 112))) AND status=1;

... FROM el_comment c, el_comment tt, el_text t
WHERE ( ( c.parent_id = tt.id AND tt.user_id = 112 AND tt.status = 1 )
    OR ( c.text_id = t.id AND  t.user_id = 112 ) ) AND c.status=1;

--
Jim Nasby                                    jimn@enterprisedb.com
EnterpriseDB      http://enterprisedb.com      512.569.9461 (cell)



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

Предыдущее
От: Jim Nasby
Дата:
Сообщение: Re: how to check the creation date of a postgres database?
Следующее
От: Jim Nasby
Дата:
Сообщение: Re: The server lacks instrumentation functions