X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2D7F552896 for ; Wed, 18 May 2005 14:54:12 -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 17652-07 for ; Wed, 18 May 2005 17:54:09 +0000 (GMT) Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id 7FE3A528B8 for ; Wed, 18 May 2005 14:54:06 -0300 (ADT) Received: (qmail 16404 invoked from network); 18 May 2005 19:54:35 +0200 Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) by boutiquenumerique.com with SMTP; 18 May 2005 19:54:35 +0200 To: "Felix E. Klee" , pgsql-sql@postgresql.org Subject: Re: Turning column into *sorted* array? References: <87zmus8qdm.wl%felix.klee@inka.de> Message-ID: 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 Date: Wed, 18 May 2005 19:54:08 +0200 In-Reply-To: <87zmus8qdm.wl%felix.klee@inka.de> User-Agent: Opera M2(BETA2)/8.0 (Linux, build 987) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/154 X-Sequence-Number: 21467 > SELECT array_accum(x) FROM (SELECT * FROM some_view ORDER BY x) AS tmp; If you're using integers, you could use the int_array_accum or something from the intarray module which is a lot faster. I believe intarray also has a function for sorting integer arrays... > > BTW, the best alternative (in terms of execution performance) that comes > into my mind is to create an aggregate that does the sorting right away > while the values "come in" from the rows. But that'd probably take me > some time to get right. >