X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id B7716D1D2E0 for ; Fri, 13 Feb 2004 05:58:38 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 45817-10 for ; Fri, 13 Feb 2004 01:58:37 -0400 (AST) Received: from ozimelb03.ozicom.com (unknown [203.185.247.100]) by svr1.postgresql.org (Postfix) with ESMTP id 081B2D1D299 for ; Fri, 13 Feb 2004 01:58:36 -0400 (AST) Content-class: urn:content-classes:message Subject: Re: Index question Date: Fri, 13 Feb 2004 16:58:32 +1100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Message-ID: X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [SQL] Index question Thread-Index: AcPx85mg8GqFroN8SuiYWtaZgXqnBAAAcatg From: "David Witham" To: "Tom Lane" Cc: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/135 X-Sequence-Number: 16826 There are 18321 records for 20040127 and so the estimate of 8839 for the = =3D case is low but it still does the right thing. There are 227197 records between '20040127' and current_date so the estimat= e in the >=3D case is accurate but the estimate for the between case is an = order of magnitude too low. However, it used the index I wanted and the >= =3D case didn't. Regards, David -----Original Message----- From: Tom Lane [mailto:tgl@sss.pgh.pa.us] Sent: Friday, 13 February 2004 16:38 To: David Witham Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] Index question=20 "David Witham" writes: > I understand that selecting count(*) will involve a scan at some > stage, but I was surprised that the index wasn't used in the >=3D case, > but was used in the between case. Given the estimated row counts in your examples, the planner's choices are not surprising. You have not given us any information on whether those estimates are accurate. regards, tom lane