X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4816C329C89 for ; Mon, 11 Oct 2004 23:03:17 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 83145-04 for ; Mon, 11 Oct 2004 22:03:07 +0000 (GMT) Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.201]) by svr1.postgresql.org (Postfix) with ESMTP id B089732A091 for ; Mon, 11 Oct 2004 23:03:08 +0100 (BST) Received: by mproxy.gmail.com with SMTP id 74so350081rnk for ; Mon, 11 Oct 2004 15:03:07 -0700 (PDT) Received: by 10.38.151.14 with SMTP id y14mr1517843rnd; Mon, 11 Oct 2004 15:03:07 -0700 (PDT) Received: by 10.38.76.43 with HTTP; Mon, 11 Oct 2004 15:03:07 -0700 (PDT) Message-ID: <37d451f70410111503755fb751@mail.gmail.com> Date: Mon, 11 Oct 2004 17:03:07 -0500 From: Rosser Schwarz Reply-To: Rosser Schwarz To: Francisco Reyes Subject: Re: Understanding explains Cc: PostgreSQL performance In-Reply-To: <20041011164950.J97379@zoraida.natserv.net> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <20041011164950.J97379@zoraida.natserv.net> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200410/145 X-Sequence-Number: 8621 while you weren't looking, Francisco Reyes wrote: > Is there any disadvantage of having the enable_seqscan off? Plenty. The planner will choose whichever plan looks "cheapest", based on the information it has available (table size, statistics, &c). If a sequential scan looks cheaper, and in your case above it clearly is, the planner will choose that query plan. Setting enable_seqscan = false doesn't actually disable sequential scans; it merely makes them seem radically more expensive to the planner, in hopes of biasing its choice towards another query plan. In your case, that margin made an index scan look less expensive than sequential scan, but your query runtimes clearly suggest otherwise. In general, it's best to let the planner make the appropriate choice without any artificial constraints. I've seen pathalogical cases where the planner makes the wrong choice(s), but upon analysis, they're almost always attributable to poor statistics, long un-vacuumed tables, &c. /rls -- :wq