pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Hassan Adekoya <hechy_man@yahoo.com>
To: pgsql-performance@postgresql.org
Subject: increment Rows in an SQL Result Set postgresql
Date: Sat, 15 Jul 2006 17:46:40 +0000 (UTC)
Message-ID: <loom.20060715T194555-176@post.gmane.org> (raw)

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!




view thread (4+ messages)  latest in thread

Message-ID: <loom.20060715T194555-176@post.gmane.org>
Permalink:  ../loom.20060715T194555-176@post.gmane.org/
Also on:    postgresql.org/message-id/loom.20060715T194555-176@post.gmane.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: hechy_man@yahoo.com
  Subject: Re: increment Rows in an SQL Result Set postgresql
  In-Reply-To: <loom.20060715T194555-176@post.gmane.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox