Re: [PERFORM] EXISTS optimization

От: Kevin Grittner
Тема: Re: [PERFORM] EXISTS optimization
Дата: ,
Msg-id: 4604104C.EE98.0025.0@wicourts.gov
(см: обсуждение, исходный текст)
Ответ на: Re: EXISTS optimization  ("Kevin Grittner")
Список: pgsql-hackers

Скрыть дерево обсуждения

EXISTS optimization  ("Kevin Grittner", )
 Re: EXISTS optimization  (Tom Lane, )
  Re: EXISTS optimization  ("Kevin Grittner", )
   Re: [PERFORM] EXISTS optimization  ("Kevin Grittner", )
   Re: EXISTS optimization  (Tom Lane, )
   Re: [PERFORM] EXISTS optimization  ("Peter Kovacs", )
  Re: EXISTS optimization  (Martijn van Oosterhout, )
   Re: EXISTS optimization  ("Kevin Grittner", )
    Re: EXISTS optimization  (Martijn van Oosterhout, )
 Re: [PERFORM] EXISTS optimization  ("Kevin Grittner", )


>>> On Fri, Mar 23, 2007 at  5:26 PM, in message
<>, "Kevin Grittner"
<> wrote:

> I tried something which seems
> equivalent, but it is running for a very long time.  I'll show it with just
> the explain while I wait to see how long the explain analyze takes.
>
> explain
> SELECT "A"."adjustmentNo", "A"."tranNo", "A"."countyNo", "H"."date",
> "H"."userId", "H"."time"
>   FROM "Adjustment" "A"
>   JOIN "TranHeader" "H" ON ("H"."tranId" = "A"."adjustmentNo" AND
> "H"."countyNo" = "A"."countyNo" AND "H"."tranNo" = "A"."tranNo")
>   WHERE "H"."tranType" = 'A'
>     AND "A"."date" > DATE '2006-  01-  01'
>     AND "H"."countyNo" = 66
>     AND "A"."countyNo" = 66
>     AND "H"."tranNo" IN
>         (
>           SELECT "D"."tranNo" FROM "TranDetail" "D"
>             WHERE "D"."caseNo" LIKE '2006TR%'
>               AND "D"."countyNo" = "H"."countyNo"
>         )
> ;

explain analyze results:

 Nested Loop  (cost=0.00..181673.08 rows=1 width=46) (actual time=42224.077..964266.969 rows=2209 loops=1)
   Join Filter: (("H"."tranId")::bpchar = ("A"."adjustmentNo")::bpchar)
   ->  Seq Scan on "Adjustment" "A"  (cost=0.00..2384.27 rows=11733 width=22) (actual time=15.355..146.620 rows=13003
loops=1)
         Filter: (((date)::date > '2006-01-01'::date) AND (("countyNo")::smallint = 66))
   ->  Index Scan using "TranHeader_pkey" on "TranHeader" "H"  (cost=0.00..15.27 rows=1 width=46) (actual
time=74.141..74.141rows=0 loops=13003) 
         Index Cond: ((("H"."tranNo")::integer = ("A"."tranNo")::integer) AND (("H"."countyNo")::smallint = 66))
         Filter: ((("tranType")::bpchar = 'A'::bpchar) AND (subplan))
         SubPlan
           ->  Index Scan using "TranDetail_TranDetCaseNo" on "TranDetail" "D"  (cost=0.00..27.66 rows=20 width=4)
(actualtime=0.039..58.234 rows=42342 loops=13003) 
                 Index Cond: ((("caseNo")::bpchar >= '2006TR'::bpchar) AND (("caseNo")::bpchar < '2006TS'::bpchar) AND
(("countyNo")::smallint= ($0)::smallint)) 
                 Filter: (("caseNo")::bpchar ~~ '2006TR%'::text)
 Total runtime: 964269.555 ms



В списке pgsql-hackers по дате сообщения:

От: "Kevin Grittner"
Дата:
Сообщение: Re: [PERFORM] EXISTS optimization
От: Grzegorz Jaskiewicz
Дата:
Сообщение: Re: Time to package 8.2.4