Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 26A4F633686 for ; Fri, 2 Jul 2010 01:09:00 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 46070-07 for ; Fri, 2 Jul 2010 04:08:52 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 375DF632F66 for ; Fri, 2 Jul 2010 01:08:52 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id o6248oMR004768; Fri, 2 Jul 2010 00:08:50 -0400 (EDT) To: Craig Ringer cc: Eliot Gable , pgsql-performance@postgresql.org Subject: Re: Highly Efficient Custom Sorting In-reply-to: <4C2D574E.5030308@postnewspapers.com.au> References: <4C2D574E.5030308@postnewspapers.com.au> Comments: In-reply-to Craig Ringer message dated "Fri, 02 Jul 2010 11:04:46 +0800" Date: Fri, 02 Jul 2010 00:08:50 -0400 Message-ID: <4767.1278043730@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.011 tagged_above=-10 required=5 tests=BAYES_20=-0.001, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201007/18 X-Sequence-Number: 39407 Craig Ringer writes: > On 02/07/10 08:46, Eliot Gable wrote: >> So, the bottom line is, I need a faster way to do this sorting. > You haven't showed us how you're doing it at the moment, so it's awfully > hard to comment usefully on possible approaches. I'm guessing from tea leaves, but the impression I got from Eliot's description is that he's using plpgsql functions as sort comparators. It's not surprising that that sucks performance-wise compared to having the equivalent logic in C/C++ functions used as comparators on the client side. plpgsql is no speed demon. Best fix might be to code the comparators as C functions on the server side. regards, tom lane