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 93021529A1 for ; Tue, 28 Jun 2005 14:10:16 -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 90319-07 for ; Tue, 28 Jun 2005 17:10:07 +0000 (GMT) Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id 5BCF752943 for ; Tue, 28 Jun 2005 14:10:06 -0300 (ADT) Received: (qmail 4440 invoked from network); 28 Jun 2005 19:10:27 +0200 Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) by boutiquenumerique.com with SMTP; 28 Jun 2005 19:10:27 +0200 To: kjelle@bingon.no, pgsql-performance@postgresql.org Subject: Re: Too slow querying a table of 15 million records References: <19310.193.213.27.25.1119378838.squirrel@webmail.s7.itpays.net> Message-ID: Date: Tue, 28 Jun 2005 19:10:05 +0200 From: PFC Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In-Reply-To: <19310.193.213.27.25.1119378838.squirrel@webmail.s7.itpays.net> User-Agent: Opera M2(BETA2)/8.0 (Linux, build 987) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200506/565 X-Sequence-Number: 13202 > database=> explain select date_trunc('hour', time),count(*) as total from > test where p1=53 and time > now() - interval '24 hours' group by > date_trunc order by date_trunc ; 1. Use CURRENT_TIMESTAMP (which is considered a constant by the planner) instead of now() 2. Create a multicolumn index on (p1,time) or (time,p1) whichever works better