Re: Query analyse

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Elielson Fontanezi <ElielsonF(at)prodam(dot)sp(dot)gov(dot)br>
Cc: pgsql-sql <pgsql-sql(at)postgresql(dot)org>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Query analyse
Date: 2003-07-25 15:49:15
Message-ID: 20030725084243.U31713-100000@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

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 2001
> 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 the
> trunc function.
>
> You can see that the TRUNC function rise hardly up the query response
> time in the second query.
> That shouldnt 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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dmitry Tkach 2003-07-25 16:05:31 Re: Query analyse
Previous Message Jonathan Bartlett 2003-07-25 15:37:37 Re: Solaris, Postgresql and Problems

Browse pgsql-sql by date

  From Date Subject
Next Message Dmitry Tkach 2003-07-25 16:05:31 Re: Query analyse
Previous Message R. van Twisk 2003-07-25 14:34:34 Re: [OT] SUMMERY Frontend recommendations