Re: [SQL] selecting random row values in postgres

2007-02-23 Thread Geoff Tolley
Tommy Gildseth wrote: Sumeet wrote: Thanks Buddy, really appreciate ur help on this problem solved... Is there any way this query can be optimized...i'm running it on a huge table with joins ORDER BY rand() is rather slow on large datasets, since the db has to actually generate a rando

Re: [SQL] selecting random row values in postgres

2007-02-23 Thread Tommy Gildseth
Sumeet wrote: Thanks Buddy, really appreciate ur help on this problem solved... Is there any way this query can be optimized...i'm running it on a huge table with joins ORDER BY rand() is rather slow on large datasets, since the db has to actually generate a random value for each row in

Re: [SQL] selecting random row values in postgres

2007-02-23 Thread Rajesh Kumar Mallah
On 2/24/07, Sumeet <[EMAIL PROTECTED]> wrote: got itI just figured out that i dont need the ORDER BY clause even the first row selected by the 'DISTINCT ON' would solve the problem. Dear Sumeet, if order by is not done there is no certainty about which row gets selected. usually same r

Re: [SQL] selecting random row values in postgres

2007-02-23 Thread Sumeet
Thanks Buddy, really appreciate ur help on this problem solved... Is there any way this query can be optimized...i'm running it on a huge table with joins - Sumeet On 2/23/07, Rajesh Kumar Mallah <[EMAIL PROTECTED]> wrote: On 2/24/07, Sumeet <[EMAIL PROTECTED]> wrote: > Hi all, > > I'

Re: [SQL] selecting random row values in postgres

2007-02-23 Thread Rajesh Kumar Mallah
On 2/24/07, Sumeet <[EMAIL PROTECTED]> wrote: Hi all, I'm trying to write a query to select random values from a set of 'GROUP BY' see the scenario below to understand the problem here (the actual problem cannot be discussed here so i'm taking an example scenario) Assume there is a table

[SQL] selecting random row values in postgres

2007-02-23 Thread Sumeet
Hi all, I'm trying to write a query to select random values from a set of 'GROUP BY' see the scenario below to understand the problem here (the actual problem cannot be discussed here so i'm taking an example scenario) Assume there is a table id | name | year_of_birth query: I want to se