Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id E74BF476000 for ; Thu, 6 Jun 2002 12:02:19 -0400 (EDT) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id A572A475E91 for ; Thu, 6 Jun 2002 12:02:17 -0400 (EDT) Received: from [63.195.55.98] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 3.5.9) with HTTP id 1501412; Thu, 06 Jun 2002 09:02:21 -0700 From: "Josh Berkus" Subject: Re: Indexing timestamps To: Andre Schubert , pgsql-sql@postgresql.org X-Mailer: CommuniGate Pro Web Mailer v.3.5.9 Date: Thu, 06 Jun 2002 09:02:21 -0700 Message-ID: In-Reply-To: <20020606104521.3b3f1b06.andre.schubert@km3.de> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Archive-Number: 200206/54 X-Sequence-Number: 8019 Andre, I'm not even going to try to deal with the seq_scan vs. index_scan issues on now(). This has been brought up in the list archives. Test your actual response times as well as the query plan; you may find that you don't have a real problem. Something I can help you with: > explain select * from test_table where date_trunc('month',time_stamp) > = date_trunc('month',datetime('2002-01-01')); > NOTICE: QUERY PLAN: > > Seq Scan on test_table (cost=0.00..2441.41 rows=584 width=16) Try doing a: CREATE INDEX idx_test_month ON test_table(extract(month FROM time_stamp)); Which should help. -Josh