X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1A726D9C35 for ; Thu, 29 Sep 2005 13:10:38 -0300 (ADT) 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 74162-07 for ; Thu, 29 Sep 2005 16:10:33 +0000 (GMT) Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id 367E6D9BF4 for ; Thu, 29 Sep 2005 13:10:32 -0300 (ADT) Received: (qmail 4924 invoked from network); 29 Sep 2005 18:11:22 +0200 Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) by boutiquenumerique.com with SMTP; 29 Sep 2005 18:11:22 +0200 Date: Thu, 29 Sep 2005 18:10:29 +0200 To: rjpeace@earthlink.net Subject: Re: [PERFORM] A Better External Sort? Cc: "Pg Hackers" , pgsql-performance@postgresql.org References: <11604324.1127974870565.JavaMail.root@elwamui-polski.atl.sa.earthlink.net> <5A8CC216-2E25-4B8C-910A-69224D0A66CE@rilk.com> From: PFC Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID: In-Reply-To: <5A8CC216-2E25-4B8C-910A-69224D0A66CE@rilk.com> User-Agent: Opera M2/8.0 (Linux, build 1095) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] X-Spam-Level: X-Archive-Number: 200509/1411 X-Sequence-Number: 73808 Just to add a little anarchy in your nice debate... Who really needs all the results of a sort on your terabyte table ? I guess not many people do a SELECT from such a table and want all the results. So, this leaves : - Really wanting all the results, to fetch using a cursor, - CLUSTER type things, where you really want everything in order, - Aggregates (Sort->GroupAggregate), which might really need to sort the whole table. - Complex queries where the whole dataset needs to be examined, in order to return a few values - Joins (again, the whole table is probably not going to be selected) - And the ones I forgot. However, Most likely you only want to SELECT N rows, in some ordering : - the first N (ORDER BY x LIMIT N) - last N (ORDER BY x DESC LIMIT N) - WHERE x>value ORDER BY x LIMIT N - WHERE x