Re: Problem with large query

From: Marc Cousin <mcousin(at)sigma(dot)fr>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Problem with large query
Date: 2004-09-08 15:17:47
Message-ID: 200409081717.47514.mcousin@sigma.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Wednesday 08 September 2004 16:56, you wrote:
> Marc Cousin <mcousin(at)sigma(dot)fr> writes:
> > The query has been generated by business objects ... i'ill try to suggest to the developpers to remove this constant (if they can)...
> > The fields used by the sort are of type numeric(6,0) or (10,0) ...
> > Could it be better if the fields were integer or anything else ?
>
> integer or bigint would be a WHOLE lot faster. I'd venture that
> comparing two numerics is order of a hundred times slower than
> comparing two integers.
>
> Even if you don't want to change the fields on-disk, you might think
> about casting them all to int/bigint in the query.
>
> Another thing that might or might not be easy is to change the order of
> the GROUP BY items so that the fields with the largest number of
> distinct values are listed first. If two rows are distinct at the first
> column, the sorting comparison doesn't even have to look at the
> remaining columns ...
>
> regards, tom lane
>
Thanks. I've just had confirmation that they can remove the two constants (allready won 100 seconds thanks to that)
I've tried the cast, and got down to 72 seconds.
So now we're going to try to convert the fields to int or bigint.

Thanks a lot for your help and time.

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Mischa Sandberg 2004-09-08 15:38:51 Re: Equivalent praxis to CLUSTERED INDEX?
Previous Message Tom Lane 2004-09-08 14:56:17 Re: Problem with large query