Re: Problem with large query - Mailing list pgsql-performance

From Tom Lane
Subject Re: Problem with large query
Date
Msg-id 20325.1094655377@sss.pgh.pa.us
Whole thread Raw
In response to Re: Problem with large query  (Marc Cousin <mcousin@sigma.fr>)
Responses Re: Problem with large query
List pgsql-performance
Marc Cousin <mcousin@sigma.fr> writes:
> The query has been generated by business objects ... i'ill try to suggest to the developpers to remove this constant
(ifthey 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

pgsql-performance by date:

Previous
From: Marc Cousin
Date:
Subject: Re: Problem with large query
Next
From: Marc Cousin
Date:
Subject: Re: Problem with large query