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 092E99DCBE3 for ; Thu, 9 Feb 2006 15:46:07 -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 20913-06 for ; Thu, 9 Feb 2006 15:46:06 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) by postgresql.org (Postfix) with ESMTP id 747F99DCBDA for ; Thu, 9 Feb 2006 15:46:04 -0400 (AST) Received: by noel.decibel.org (Postfix, from userid 1001) id B13C839834; Thu, 9 Feb 2006 19:46:05 +0000 (UTC) Received: (hashcash-sendmail, from uid 1001); Thu, 9 Feb 2006 13:46:03 -0600 Date: Thu, 9 Feb 2006 13:46:03 -0600 From: "Jim C. Nasby" To: Dave Dutcher Cc: 'Rafael Martinez Guerrero' , pgsql-performance@postgresql.org Subject: Re: Help with optimizing a sql statement Message-ID: <20060209194603.GX57845@pervasive.com> References: <20060209193345.GV57845@pervasive.com> <001f01c62db1$3a380910$8300a8c0@tridecap.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <001f01c62db1$3a380910$8300a8c0@tridecap.com> X-Operating-System: FreeBSD 6.0-RELEASE amd64 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.11 X-Hashcash: 1:20:060209:dave@tridecap.com::G5+En4JrsmsqugtM:00000000000000000000 00000000000000000000000026KF X-Hashcash: 1:20:060209:r.m.guerrero@usit.uio.no::RCIxqUNYmltyk9S1:0000000000000 000000000000000000000000BDqG X-Hashcash: 1:20:060209:pgsql-performance@postgresql.org::Pbk5hlB0IAZyuADj:00000 0000000000000000000000005nqf X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.104 required=5 tests=[AWL=0.104] X-Spam-Score: 0.104 X-Spam-Level: X-Archive-Number: 200602/86 X-Sequence-Number: 17072 I looked at the estimates for the table access methods and they all looked ok, so I think the statistics are pretty up-to-date; there just aren't enough of them for the planner to do a good job. On Thu, Feb 09, 2006 at 01:44:22PM -0600, Dave Dutcher wrote: > 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] > > > ---------------------------(end of broadcast)--------------------------- > TIP 1: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly > -- Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com Pervasive Software http://pervasive.com work: 512-231-6117 vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461