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 BDB5632A00F for ; Wed, 6 Oct 2004 04:30:15 +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 43204-08 for ; Wed, 6 Oct 2004 03:30:06 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 7E8CC32A003 for ; Wed, 6 Oct 2004 04:30:04 +0100 (BST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id i963Turd020688; Tue, 5 Oct 2004 23:29:57 -0400 (EDT) To: Nichlas =?iso-8859-1?Q?L=F6fdahl?= Cc: pgsql-performance@postgresql.org Subject: Re: Planner picks the wrong plan? In-reply-to: <20041006004204.GA13074@shaka.acc.umu.se> References: <20041006004204.GA13074@shaka.acc.umu.se> Comments: In-reply-to Nichlas =?iso-8859-1?Q?L=F6fdahl?= message dated "Wed, 06 Oct 2004 02:42:04 +0200" Date: Tue, 05 Oct 2004 23:29:56 -0400 Message-ID: <20687.1097033396@sss.pgh.pa.us> From: Tom Lane 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/51 X-Sequence-Number: 8527 Nichlas =?iso-8859-1?Q?L=F6fdahl?= writes: > My question is, why doesn't the planner pick the same plan for Q1 & Q3? I think it's mostly that after you've added and ANALYZEd the "age" column, the planner has a pretty good idea of how many rows will pass the "age > 17 AND age < 20" condition. It can't do very much with the equivalent condition in the original form, though, and in fact ends up drastically underestimating the number of matching rows (86 vs reality of 3021). That leads directly to a bad plan choice :-( regards, tom lane