X-Original-To: pgsql-performance-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 2BB419FB324 for ; Mon, 26 Jun 2006 09:20:50 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 52088-01 for ; Mon, 26 Jun 2006 09:20:46 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) by postgresql.org (Postfix) with ESMTP id B37059FB4F7 for ; Mon, 26 Jun 2006 05:49:04 -0300 (ADT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id 8414D30920; Mon, 26 Jun 2006 10:49:03 +0200 (MET DST) From: "Andrus" X-Newsgroups: pgsql.performance Subject: Re: why group expressions cause query to run forever Date: Mon, 26 Jun 2006 11:48:47 +0300 Organization: Hub.Org Networking Services Lines: 27 Message-ID: References: <2851.1151004624@sss.pgh.pa.us> X-Complaints-To: usenet@news.hub.org X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2869 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 X-RFC2646: Format=Flowed; Original To: pgsql-performance@postgresql.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/472 X-Sequence-Number: 19829 Tom, thank you. > I think the problem is probably that you're sorting two dozen CHAR > columns, and that in many of the rows all these entries are '' forcing > the sort code to compare all two dozen columns (not so)? So the sort > ends up doing lots and lots and lots of CHAR comparisons. Which can > be slow, especially in non-C locales. What's your locale setting? show all returns "lc_collate";"en_US.UTF-8" "lc_ctype";"en_US.UTF-8" "lc_messages";"C" "lc_monetary";"et_EE.utf-8" "lc_numeric";"et_EE.utf-8" "lc_time";"et_EE.utf-8" How to speed up this query ? Is it possible to force the binary comparison for grouping ? Should I concatenate all the char columns into single column ? Andrus.