X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 91CC5D1C91D; Fri, 25 Jul 2003 15:49:18 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 50379-09; Fri, 25 Jul 2003 12:48:31 -0300 (ADT) Received: from megazone.bigpanda.com (unknown [66.180.233.26]) by svr1.postgresql.org (Postfix) with ESMTP id 97662D1C91E; Fri, 25 Jul 2003 12:49:17 -0300 (ADT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id BE05FD638; Fri, 25 Jul 2003 08:49:15 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id ABAA05C0E; Fri, 25 Jul 2003 08:49:15 -0700 (PDT) Date: Fri, 25 Jul 2003 08:49:15 -0700 (PDT) From: Stephan Szabo To: Elielson Fontanezi Cc: pgsql-sql , pgsql-general Subject: Re: Query analyse In-Reply-To: Message-ID: <20030725084243.U31713-100000@megazone.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN Content-Transfer-Encoding: QUOTED-PRINTABLE X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/1233 X-Sequence-Number: 46086 On Fri, 25 Jul 2003, Elielson Fontanezi wrote: > First of all, my envoronment is: > Linux netlab142.prodam 2.4.8-26mdk #1 Sun Sep 23 17:06:39 CEST 20= 01 > i686 unknown > pg_ctl (PostgreSQL) 7.2.1 > > I would like some suggestions on how to speed up a query. > > Both of the queries below are identical except that one of them use t= he > trunc function. > > You can see that the TRUNC function rise hardly up the query response > time in the second query. > That shouldn=B4t be happen. Only because a trunc function? > > What can I be in that case? > What does it happen? What does explain show for the two queries and what are the table schemas? You're probably ending up with different plans since in one case it has a plain column reference and in the other it has a marginally complicated expression in the join condition. As something to try, perhaps make a function that returns trunc($1/100000.0)*100000 and index on that function for the column and see if that changes the plan you get.