Re: problem in select

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: problem in select
Дата
Msg-id 20020916173621.B15848@svana.org
обсуждение исходный текст
Ответ на Re: problem in select  ("frank_lupo" <frank_lupo@email.it>)
Список pgsql-general
Well, here's your problem. Using both IN (which is slow) and DISTINCT (which
is completely unnessesary).

How does this differ from:

select titolo,id,anno
from ircalend
where anno=2002
and exists (select 1 from ircalend_3 where idcalen=ircalend.id)
order by anno,titolo;

On Mon, Sep 16, 2002 at 08:46:27AM +0200, frank_lupo wrote:
> gedis30=# explain select titolo,id,anno from ircalend where anno=2002 and id in(select distinct(idcalend) from
ircalend_3)order by anno,titolo; 
> NOTICE:  QUERY PLAN:
> Sort  (cost=47353.16..47353.16 rows=1 width=49)
>   ->  Seq Scan on ircalend  (cost=0.00..47353.15 rows=1 width=49)
>         SubPlan
>           ->  Materialize  (cost=6764.58..6764.58 rows=7111 width=4)
>                 ->  Unique  (cost=0.00..6764.58 rows=7111 width=4)
>                       ->  Index Scan using ircalend_3_idcalend on ircalend_3  (cost=0.00..6586.80 rows=71112 width=4)
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> There are 10 kinds of people in the world, those that can do binary
> arithmetic and those that can't.

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

Предыдущее
От: "frank_lupo"
Дата:
Сообщение: Re: problem in select
Следующее
От: Manfred Koizar
Дата:
Сообщение: Re: postgres crash