X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id ACDA4D1B507 for ; Sun, 28 Sep 2003 21:35:12 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 30546-02 for ; Sun, 28 Sep 2003 18:35:04 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id EA281D1B4F2 for ; Sun, 28 Sep 2003 18:35:01 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3692350; Sun, 28 Sep 2003 14:35:35 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Palle Girgensohn , pgsql-performance@postgresql.org Subject: Re: avoiding seqscan? Date: Sun, 28 Sep 2003 14:34:25 -0700 User-Agent: KMail/1.4.3 References: <95900000.1064782481@palle.girgensohn.se> In-Reply-To: <95900000.1064782481@palle.girgensohn.se> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200309281434.25881.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/348 X-Sequence-Number: 3714 Palle, > I have a SQL statement that I cannot get to use the index. postgresql > insists on using a seqscan and performance is very poor. set enable_seqscan > = true boost performance drastically, as you can see below. Since seqscan > is not always bad, I'd rather not turn it off completely, but rather get > the planner to do the right thing here. Is there another way to do this, > apart from setting enable_seqscan=false? In your postgresql.conf, try setting effective_cache_size to something like 50% of your system's RAM, and lovering random_page_cost to 2.0 or even 1.5. Then restart PostgreSQL and try your query again. What version, btw? -- Josh Berkus Aglio Database Solutions San Francisco