Received: from localhost (unknown [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 86E689F9FCD for ; Tue, 4 Sep 2007 11:11:26 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 87439-03-2 for ; Tue, 4 Sep 2007 11:11:21 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from rv-out-0910.google.com (rv-out-0910.google.com [209.85.198.185]) by postgresql.org (Postfix) with ESMTP id 838AB9F9FE8 for ; Tue, 4 Sep 2007 11:11:20 -0300 (ADT) Received: by rv-out-0910.google.com with SMTP id l15so1091111rvb for ; Tue, 04 Sep 2007 07:11:18 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=FJq1DyBi1to6H4Y4aG1wONN121nCkeCWkrWdhYzN1oD+2eXdl/x1n3OHwkFnLdMYq2k33LIT2gDYwlMnln+U8uYHIlJ/3dHH1N+krJoUxWTmPd0yQfQC04hElcLya716q9Mp5iOAEqcf2hGDpbhCnlC4P3okjVWgLFaRcdfkjT4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=sS7fehHUSFeK2DqS/H3HGgrtJaIYwaMFnJQCdJU0+iTs1CJQRYjWfgOEzqA9hkkwGi/VXYNrlDCOmBPUGBERrbVwP2ySmnCsqSczPugkojwarWOl5bpCkTXWBBPzQ00H5LKeHMJvQ92sBo2HNL9ayTxfNVau0oobCw2WdeqHUNg= Received: by 10.140.132.8 with SMTP id f8mr2317110rvd.1188915078833; Tue, 04 Sep 2007 07:11:18 -0700 (PDT) Received: by 10.141.159.11 with HTTP; Tue, 4 Sep 2007 07:11:18 -0700 (PDT) Message-ID: Date: Tue, 4 Sep 2007 09:11:18 -0500 From: "Scott Marlowe" To: "Richard Ray" Subject: Re: How to influence the planner Cc: pgsql-sql@postgresql.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <373D2F52-E9CD-485A-9BF1-B019349FA5EC@seespotcode.net> <2005.1188596277@sss.pgh.pa.us> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200709/34 X-Sequence-Number: 29247 On 8/31/07, Richard Ray wrote: > Changing to enable_seqscan = on does solve this problem, thanks > Is there some method of crafting a query that will assert my wishes to the planner > When is enable_seqscan = off appropriate enable_xxx = off are troubleshooting tools. They override the query planner. For instance, I had a query that was running slow, and using set enable_nestloop=off allowed the query to run fast. However, using explain analyze I could see that the estimated number of rows was off. Analyze didn't fix it, so I increased the stats target for the column I was working with, reanalyzed, and voila, the query ran fine with nestloop=on. So, enable_xxx=off is normally only appropriate when troubleshooting an issue, not as a fix all. That's doubly true for enable_seqscan=off. If you do have a query that nothing else seems to work on it, you can set one of the enable_xxx settings off for that connection only and not worry about messing up all the other sessions connecting to your db.