From: | Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> |
---|---|
To: | Alexander Dederer <dederer(at)spb(dot)cityline(dot)ru> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Re: Unusual slowdown using subselects |
Date: | 2001-05-18 15:16:36 |
Message-ID: | Pine.BSF.4.21.0105180812470.42575-100000@megazone23.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> In my DB:
> # explain SELECT * FROM grls WHERE grls.ag_id = 24;
> NOTICE: QUERY PLAN:
> Index Scan using grls_ag_id on grls (cost=0.00..597.87 rows=849 width=122)
>
> # explain SELECT ag_id FROM agncs WHERE ag_id = 24;
> NOTICE: QUERY PLAN:
> Seq Scan on agncs (cost=0.00..1.31 rows=1 width=4)
>
> And together:
> # explain select * from grls where grls.ag_id in (select ag_id from agncs
> where ag_id = 24);
> NOTICE: QUERY PLAN:
> Seq Scan on grls (cost=0.00..40623.38 rows=30195 width=122)
> SubPlan
> -> Materialize (cost=1.31..1.31 rows=1 width=4)
> -> Seq Scan on agncs (cost=0.00..1.31 rows=1 width=4)
> --------------------------------------
> # select count(*) from grls;
> 30195
>
> Summarize - with subselect indices ignores and search look all DB rows.
Not quite. in(<subselect>) doesn't use indexes (postgres doesn't realize
that this is effectively a join), but exists(<subselect>) often will,
and is the work around for the problem until it gets fixed (see FAQ
for more information - I forget the number, the title of the question
is something like "why are my subselects using in so slow."
From | Date | Subject | |
---|---|---|---|
Next Message | Borek Lupoměský | 2001-05-18 15:18:52 | Warnings on pg_dump |
Previous Message | Dave Cramer | 2001-05-18 15:16:19 | Re: Java Access to Postgresql |