pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kevin Grittner <Kevin.Grittner@wicourts.gov>
To: Tom Lane <tgl@sss.pgh.pa.us>
To: Kevin Grittner <Kgrittn.CCAP.Courts@wicourts.gov>
Cc: pgsql-hackers@postgresql.org
Cc: pgsql-performance@postgresql.org
Cc: Andrea Olson <Aolson.CCAP.Courts@wicourts.gov>
Cc: Bill Severson <BSEVERS.CCAP.Courts@wicourts.gov>
Cc: John Hutchins <jhutchi.CCAP.Courts@wicourts.gov>
Cc: Randy Peterson <RPETERS.CCAP.Courts@wicourts.gov>
Cc: Shannon Spranger <ssprang.CCAP.Courts@wicourts.gov>
Subject: Re: [PERFORM] EXISTS optimization
Date: Fri, 23 Mar 2007 17:37:16 -0500
Message-ID: <4604104C.EE98.0025.0@wicourts.gov> (raw)
In-Reply-To: <46040DAC.EE98.0025.0@wicourts.gov>
References: <4603C1A3.EE98.0025.0@wicourts.gov>
	<4603C1A3.EE98.0025.0@wicourts.gov>
	<25339.1174686582@sss.pgh.pa.us>
	<46040DAC.EE98.0025.0@wicourts.gov>



>>> On Fri, Mar 23, 2007 at  5:26 PM, in message
<46040DAC.EE98.0025.0@wicourts.gov>, "Kevin Grittner"
<Kevin.Grittner@wicourts.gov> 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.141 rows=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) (actual time=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




view thread (12+ messages)  latest in thread

Message-ID: <4604104C.EE98.0025.0@wicourts.gov>
Permalink:  ../4604104C.EE98.0025.0@wicourts.gov/
Also on:    postgresql.org/message-id/4604104C.EE98.0025.0@wicourts.gov

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: Kevin.Grittner@wicourts.gov, tgl@sss.pgh.pa.us, Kgrittn.CCAP.Courts@wicourts.gov, pgsql-hackers@postgresql.org, Aolson.CCAP.Courts@wicourts.gov, BSEVERS.CCAP.Courts@wicourts.gov, jhutchi.CCAP.Courts@wicourts.gov, RPETERS.CCAP.Courts@wicourts.gov, ssprang.CCAP.Courts@wicourts.gov
  Subject: Re: [PERFORM] EXISTS optimization
  In-Reply-To: <4604104C.EE98.0025.0@wicourts.gov>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox