X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B395BD1B297 for ; Thu, 15 Jul 2004 11:29:41 -0300 (ADT) 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 92685-04 for ; Thu, 15 Jul 2004 14:29:48 +0000 (GMT) Received: from amitabha.axelero.hu (fe04.axelero.hu [195.228.240.92]) by svr1.postgresql.org (Postfix) with ESMTP id ADA55D1B18F for ; Thu, 15 Jul 2004 11:29:37 -0300 (ADT) Received: from amitabha (localhost-02 [127.0.2.1]) by amitabha.axelero.hu (8.12.11/8.12.11) with SMTP id i6FETlsK012694 for ; Thu, 15 Jul 2004 16:29:47 +0200 (CEST) Received: from fe04.axelero.hu [127.0.2.1] via SMTP gateway by amitabha [195.228.240.92]; id A0318EC611B at Thu, 15 Jul 2004 16:29:46 +0200 Received: from fejleszt4 (121-248-182-81.adsl-fixip.axelero.hu [81.182.248.121]) by fe04.axelero.hu (8.12.11/8.12.11) with SMTP id i6FETi3H012638 for ; Thu, 15 Jul 2004 16:29:45 +0200 (CEST) Message-ID: <00d701c46a78$1d675eb0$0403a8c0@fejleszt4> From: =?iso-8859-1?Q?SZUCS_G=E1bor?= To: References: <40F44635.6050202@ricker.us> Subject: Re: How do I convice postgres to use an index? Date: Thu, 15 Jul 2004 16:29:17 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 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: 200407/92 X-Sequence-Number: 18344 Try casting the constant to the type of the field, i.e. WHERE timestamp >= '7/12/2004'::"timestamp without time zone" (iirc the quotes are necessary) Also, I'd try to avoid naming attributes like (built-in) types. (iirc "timestamp" is a type without time zone in 7.3, and with time zone in 7.4 :) "timestamptz" is the opposite in both cases) G. %----------------------- cut here -----------------------% \end ----- Original Message ----- From: "Vic Ricker" Sent: Tuesday, July 13, 2004 10:29 PM > I apologize for the following stupid question. I have been doing some > searching and haven't found anything really helpful. > > The problem is that postgres (7.4.2) keeps choosing to do a sequential > scan on a table when an index scan would be significantly faster. > > The queries that I'm using look at daily statistics from events logged > by our Checkpoint firewall and generate graphs. Since they are bit > complicated, I simplified it to "select count(*) from log where > timestamp>='7/12/2004'" for testing.