From: | Martijn van Oosterhout <kleptog(at)svana(dot)org> |
---|---|
To: | frank_lupo <frank_lupo(at)email(dot)it> |
Cc: | dev <dev(at)archonet(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: problem in select |
Date: | 2002-09-16 07:36:21 |
Message-ID: | 20020916173621.B15848@svana.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)svana(dot)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.
From | Date | Subject | |
---|---|---|---|
Next Message | Manfred Koizar | 2002-09-16 08:31:40 | Re: postgres crash |
Previous Message | frank_lupo | 2002-09-16 06:49:00 | Re: problem in select |