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 C1D519DCC09 for ; Thu, 9 Feb 2006 15:44:28 -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 19755-09 for ; Thu, 9 Feb 2006 15:44:28 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from globalrelay.com (mail1.globalrelay.com [216.18.71.77]) by postgresql.org (Postfix) with ESMTP id 51B549DCBE3 for ; Thu, 9 Feb 2006 15:44:23 -0400 (AST) X-Virus-Scanned: Scanned by GRC-AntiVirus Gateway X-GR-Acctd: YES Received: from [63.226.156.118] (HELO DaveEMachine) by globalrelay.com (CommuniGate Pro SMTP 4.2.3) with ESMTP id 83342339; Thu, 09 Feb 2006 11:44:23 -0800 From: "Dave Dutcher" To: "'Rafael Martinez Guerrero'" Cc: Subject: Re: Help with optimizing a sql statement Date: Thu, 9 Feb 2006 13:44:22 -0600 Message-ID: <001f01c62db1$3a380910$8300a8c0@tridecap.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2627 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 In-Reply-To: <20060209193345.GV57845@pervasive.com> Importance: Normal X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.06 required=5 tests=[AWL=0.060] X-Spam-Score: 0.06 X-Spam-Level: X-Archive-Number: 200602/83 X-Sequence-Number: 17069 First I'm wondering if the tables have been recently analyzed. If an analyze has been run recently, then it is probably a good idea to look at the statistics target. -----Original Message----- From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Jim C. Nasby Sent: Thursday, February 09, 2006 1:34 PM To: Rafael Martinez Guerrero Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] Help with optimizing a sql statement At least part of the problem is that it's way off on some of the row estimates. I'd suggest upping the statisticss target on at least all of the join columns to at least 100. (Note that it's doing a nested loop thinking it will have only 2 rows but it actually has 22000 rows). On Thu, Feb 09, 2006 at 04:10:27PM +0100, Rafael Martinez Guerrero wrote: > Hello > > We are running an application via web that use a lot of time to perform > some operations. We are trying to find out if some of the sql statements > used are the reason of the slow speed. > > We have identified a sql that takes like 4-5000ms more than the second > slowest sql in out test server. I hope that we will get some help to try > to optimize it. > > Thanks in advance for any help. > [Snip]