Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 0E30B9FBF39 for ; Wed, 30 May 2007 15:08:17 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 00491-01-3 for ; Wed, 30 May 2007 15:08:02 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from web52704.mail.re2.yahoo.com (web52704.mail.re2.yahoo.com [206.190.48.227]) by postgresql.org (Postfix) with SMTP id 2FCDA9FC015 for ; Wed, 30 May 2007 15:08:04 -0300 (ADT) Received: (qmail 38448 invoked by uid 60001); 30 May 2007 18:08:02 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type:Message-ID; b=z5HLDseTntLfKVSzZRV+dfEFwJKp6UWfOzkzZy9BJt+qMfQ7a3VFauQu1BffutB3R/UpuwluP7P7bVANSGqKpDjtgFT44r6TGvnW7mx38YhyXpsBUFo67Vw4ytrTS7/H+90KAxuCwbnqmWJZUGxL8TwRrKwy9Tkqj0yB01IEFYg=; X-YMail-OSG: A4fgjiAVM1mXN5jdeY0lTccmTtTQ_ijLWktu3oNFKsiW_o6cjXic_VPPT.ZC6zN9sPN4c5z5wNUSpbuFbhDWaqF7CXp2mEw_B1bhHIyFcAvA1oxcI9MfXCSSP5EK8icng4jaXmob0UCImpRwTHJ1cMlKqA-- Received: from [195.168.227.227] by web52704.mail.re2.yahoo.com via HTTP; Wed, 30 May 2007 11:08:02 PDT X-Mailer: YahooMailRC/651.23.1 YahooMailWebService/0.7.41.14 Date: Wed, 30 May 2007 11:08:02 -0700 (PDT) From: Trigve Siver Subject: Re: slow query execution To: pgsql-sql@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=ascii Message-ID: <210031.38017.qm@web52704.mail.re2.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=2.8 tagged_above=0 required=5 tests=AWL=0.185, BAYES_20=-0.74, DNS_FROM_RFC_ABUSE=0.2, DNS_FROM_RFC_POST=1.708, DNS_FROM_RFC_WHOIS=1.447 X-Spam-Level: ** X-Archive-Number: 200705/198 X-Sequence-Number: 28478 >----- Original Message ---- >From: Andrew Sullivan >To: pgsql-sql@postgresql.org >Sent: Wednesday, May 30, 2007 7:39:18 PM >Subject: Re: [SQL] slow query execution > >On Wed, May 30, 2007 at 10:03:16AM -0700, Trigve Siver wrote: >> Hi, Thanks for reply, As you have mentioned I need to get row >> numbers for my query, so when I make some other query with same >> data I will know which row number has a particular ID. > >Oh, wait. If _that's_ your plan, then this will never work. The >data could change, and your row numbers would come out wrong. >What do you need "row numbers" for anyway? The very idea is inimical >to SQL, because the data is fundamentally unordered. I want to do it only for some queries. So when I need query like that "SELECT * from t1" I need to add row_numbers there. So I will have "query with row_numbers" (where row_numbers are row numbers of my virtual list view). Then when I perform search I also get row_numbers for IDs of search result and I can highlight items in my list view. I haven't found other solution that met my requirements. I want also do it with cursors. [...] >I think there's some nifty way to get generate_series to do this too, >but I don't know it offhand (generating row numbers sounds to me like >a bad idea, so I don't do it). I have tried with generate_series but without success. thanks Trigve ____________________________________________________________________________________Luggage? GPS? Comic books? Check out fitting gifts for grads at Yahoo! Search http://search.yahoo.com/search?fr=oni_on_mail&p=graduation+gifts&cs=bz