X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 035BA5391E for ; Fri, 15 Apr 2005 11:06:20 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 21239-10 for ; Fri, 15 Apr 2005 14:06:10 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 2BCCB53BE3 for ; Fri, 15 Apr 2005 11:06:09 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j3FE66AG002800; Fri, 15 Apr 2005 10:06:06 -0400 (EDT) To: "Joel Fradkin" Cc: "'Dave Held'" , "'PERFORM'" Subject: Re: speed of querry? In-reply-to: <000001c541bc$c538fab0$797ba8c0@jfradkin> References: <000001c541bc$c538fab0$797ba8c0@jfradkin> Comments: In-reply-to "Joel Fradkin" message dated "Fri, 15 Apr 2005 09:12:25 -0400" Date: Fri, 15 Apr 2005 10:06:06 -0400 Message-ID: <2799.1113573966@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200504/343 X-Sequence-Number: 11740 "Joel Fradkin" writes: > "Merge Join (cost=49697.60..50744.71 rows=14987 width=113) (actual > time=11301.160..12171.072 rows=160593 loops=1)" > " Merge Cond: ("outer".locationid = "inner".locationid)" > " -> Sort (cost=788.81..789.89 rows=432 width=49) (actual > time=3.318..3.603 rows=441 loops=1)" > " Sort Key: l.locationid" > " -> Index Scan using ix_location on tbllocation l > (cost=0.00..769.90 rows=432 width=49) (actual time=0.145..2.283 rows=441 > loops=1)" > " Index Cond: ('SAKS'::text = (clientnum)::text)" > " -> Sort (cost=48908.79..49352.17 rows=177352 width=75) (actual > time=11297.774..11463.780 rows=160594 loops=1)" > " Sort Key: a.locationid" > " -> Merge Right Join (cost=26247.95..28942.93 rows=177352 > width=75) (actual time=8357.010..9335.362 rows=177041 loops=1)" > " Merge Cond: ((("outer".clientnum)::text = > "inner"."?column10?") AND ("outer".id = "inner".jobtitleid))" > " -> Index Scan using ix_tbljobtitle_id on tbljobtitle jt > (cost=0.00..243.76 rows=6604 width=37) (actual time=0.122..12.049 rows=5690 > loops=1)" > " Filter: (1 = presentationid)" > " -> Sort (cost=26247.95..26691.33 rows=177352 width=53) > (actual time=8342.271..8554.943 rows=177041 loops=1)" > " Sort Key: (a.clientnum)::text, a.jobtitleid" > " -> Index Scan using ix_associate_clientnum on > tblassociate a (cost=0.00..10786.17 rows=177352 width=53) (actual > time=0.166..1126.052 rows=177041 loops=1)" > " Index Cond: ((clientnum)::text = 'SAKS'::text)" > "Total runtime: 12287.502 ms" It strikes me as odd that the thing isn't considering hash joins for at least some of these steps. Can you force it to (by setting enable_mergejoin off)? If not, what are the datatypes of the join columns exactly? regards, tom lane