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 A3CCB329CB0 for ; Wed, 8 Sep 2004 16:17:53 +0100 (BST) 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 14228-09 for ; Wed, 8 Sep 2004 15:17:50 +0000 (GMT) Received: from mercure.sigma.fr (mercure-1.sigma.fr [195.25.81.8]) by svr1.postgresql.org (Postfix) with ESMTP id 4710D329CA4 for ; Wed, 8 Sep 2004 16:17:49 +0100 (BST) Received: from localhost (localhost [127.0.0.1]) by mercure.sigma.fr (Postfix) with ESMTP id D6D587A4E; Wed, 8 Sep 2004 17:17:48 +0200 (CEST) Received: from mercure.sigma.fr ([127.0.0.1]) by localhost (mercure-1 [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 09373-05; Wed, 8 Sep 2004 17:17:48 +0200 (CEST) Received: from marc.sigma.fr (unknown [89.195.0.5]) by mercure.sigma.fr (Postfix) with ESMTP id BB91B79E5; Wed, 8 Sep 2004 17:17:48 +0200 (CEST) From: Marc Cousin Organization: Sigma Informatique To: Tom Lane Subject: Re: Problem with large query Date: Wed, 8 Sep 2004 17:17:47 +0200 User-Agent: KMail/1.7 References: <200409081549.49537.mcousin@sigma.fr> <200409081650.00228.mcousin@sigma.fr> <20325.1094655377@sss.pgh.pa.us> In-Reply-To: <20325.1094655377@sss.pgh.pa.us> Cc: pgsql-performance@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200409081717.47514.mcousin@sigma.fr> X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at sigma.fr X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200409/52 X-Sequence-Number: 8180 On Wednesday 08 September 2004 16:56, you wrote: > Marc Cousin 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.