X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id A2BD0D1E854 for ; Wed, 21 Jan 2004 19:27:16 +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 19191-05 for ; Wed, 21 Jan 2004 15:26:46 -0400 (AST) Received: from davinci.ethosmedia.com (server228.ethosmedia.com [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id A2207D1CCB1 for ; Wed, 21 Jan 2004 15:06:36 -0400 (AST) Received: from [63.195.55.98] (HELO 192.168.1.29) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 4293597; Wed, 21 Jan 2004 11:07:39 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "Arnau" , Subject: Re: Queries with timestamps Date: Wed, 21 Jan 2004 11:06:06 -0800 User-Agent: KMail/1.5.4 References: <029701c3e04b$ea608930$3c0aa8c0@iberica.andromeiberica.com> In-Reply-To: <029701c3e04b$ea608930$3c0aa8c0@iberica.andromeiberica.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200401211106.06506.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/212 X-Sequence-Number: 5386 Arnau, > As the number of rows grows the time needed to execute this query takes > longer. What'd I should do improve the performance of this query? Tip #1) add an index to the timestamp column Tip #2) make sure that you VACUUM and ANALYZE regularly Tip #3) You will get better performance if you pass the "current_date - 1 month" as a constant from the client instead of in the query. This is a known issue, expected to be fixed in 7.5. -- -Josh Berkus Aglio Database Solutions San Francisco