X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 6D48A9DCC42 for ; Mon, 28 Nov 2005 20:01:08 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 72712-04 for ; Mon, 28 Nov 2005 20:00:32 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id A4F439DCC57 for ; Mon, 28 Nov 2005 20:00:27 -0400 (AST) 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 jAT00U6S017299; Mon, 28 Nov 2005 19:00:30 -0500 (EST) To: Bricklen Anderson cc: David Gagnon , pgsql-performance@postgresql.org Subject: Re: Please help with this explain analyse... In-reply-to: <438B96C6.4090902@PresiNET.com> References: <438B958B.3010602@siunik.com> <438B96C6.4090902@PresiNET.com> Comments: In-reply-to Bricklen Anderson message dated "Mon, 28 Nov 2005 15:46:14 -0800" Date: Mon, 28 Nov 2005 19:00:30 -0500 Message-ID: <17298.1133222430@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.004 required=5 tests=[AWL=0.004] X-Spam-Score: 0.004 X-Spam-Level: X-Archive-Number: 200511/544 X-Sequence-Number: 15801 Bricklen Anderson writes: > Your loops are what is causing the time spent. > eg. "actual time=0.127..17.379 rows=1154 loops=8335)" == > 8335*(17.379-0.127)/1000=>143 secs (if my math is correct). As for where the problem is, I think it's the horrid misestimate of the number of matching rows in cs_pk: >> " -> Index Scan using cs_pk on cs (cost=0.00..12.83 >> rows=2 width=144) (actual time=0.087..444.999 rows=13587 loops=1)" >> " Index Cond: (('M'::text = (cs.csypnum)::text) >> AND ((cs.csglnum)::text = ("outer".glnum)::text))" Has that table been ANALYZEd recently? How about the gl table? regards, tom lane