X-Original-To: pgsql-performance-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id D12D99FB216 for ; Sat, 15 Jul 2006 15:05:16 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 65592-07 for ; Sat, 15 Jul 2006 18:05:13 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by postgresql.org (Postfix) with ESMTP id 20AA09FA4A8 for ; Sat, 15 Jul 2006 15:05:10 -0300 (ADT) Received: from root by ciao.gmane.org with local (Exim 4.43) id 1G1oVi-00044J-1M for pgsql-performance@postgresql.org; Sat, 15 Jul 2006 20:05:02 +0200 Received: from 7Cust139.VR3.NYC4.broadband.uu.net ([63.13.248.139]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 15 Jul 2006 20:05:02 +0200 Received: from hechy_man by 7Cust139.VR3.NYC4.broadband.uu.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 15 Jul 2006 20:05:02 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-performance@postgresql.org From: Hassan Adekoya Subject: increment Rows in an SQL Result Set postgresql Date: Sat, 15 Jul 2006 17:46:40 +0000 (UTC) Lines: 44 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: main.gmane.org User-Agent: Loom/3.14 (http://gmane.org/) X-Loom-IP: 63.13.248.139 (Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050524 Fedora/1.0.4-4 Firefox/1.0.4) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200607/148 X-Sequence-Number: 20008 HI, 1. I have a function that given two parameter produces an arbitrary id, and text. However arbitrary the id and text are, they are in certain order. i.e. it is imperative that whatever processing I do, the order is preserved. 2. An odd thing happens when I perform a join on the result set such that the order that I hope to preserved in destroyed. The same result set but different ordering. I gather this is due to the query planner. Enough said. I was hoping to insert a counter in the select query of 1. such that when I perform the join of 2, I can order by the counter. i.e. 1. select id, astext from function1(1,2) 2. select id, astext, table2.name from function1(1,2) as tmp, table2 where tmp.id = table2.id when I perform 1., I get something of sort id | astext 2 | abc 6 | efg 3 | fhg I will like to preserve ordering.... When I perform 2, I get somthing of sort id | astext | table2.name 6 | efg | joe 2 | abc | zyi 3 | fgh | mec Can someone help such that I get something like id | astext | table2.name | increment 6 | efg | joe | 2 2 | abc | zyi | 1 3 | fgh | mec | 3 Thanks!