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 85C6552805 for ; Wed, 18 May 2005 05:28:23 -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 13241-10 for ; Wed, 18 May 2005 08:28:22 +0000 (GMT) Received: from quasar.skima.is (quasar.skima.is [212.30.200.205]) by svr1.postgresql.org (Postfix) with ESMTP id 500A652800 for ; Wed, 18 May 2005 05:28:20 -0300 (ADT) Received: from gnari ([85.220.28.44] [85.220.28.44]) by quasar.skima.is with ESMTP; Wed, 18 May 2005 08:28:21 Z Subject: Re: Does Postgresql have a similar pseudo-column "ROWNUM" as From: Ragnar =?ISO-8859-1?Q?Hafsta=F0?= To: Alain Cc: Sql-Postgre In-Reply-To: <428AA569.3010708@pobox.com> References: <20050517170636.GC12405@phlogiston.dyndns.org> <428A2E81.2060501@pobox.com> <1116353539.26520.5.camel@localhost.localdomain> <428A3B54.4070902@pobox.com> <1116367382.9362.11.camel@localhost.localdomain> <428AA569.3010708@pobox.com> Content-Type: text/plain; charset=ISO-8859-1 Date: Wed, 18 May 2005 08:28:25 +0000 Message-Id: <1116404906.9362.19.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.2.1.1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.002 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/146 X-Sequence-Number: 21459 On Tue, 2005-05-17 at 23:16 -0300, Alain wrote: > > Ragnar Hafstaš escreveu: > >>[how to solve the get next 100 records problem] > BUT, I think that this is close to a final solution, I made some > preliminary test ok. Please tell me what you think about this. > > Fisrt let's state that I am reading records to put on a screen (in a > Table/Grid). I separated the problem is *3* parts > > -first select is as above: > select ... from tab ORDER by skey,pkey LIMIT 100; > > -second method for next 100: > select ... from tab WHERE skey>=skey_last > ORDER BY skey,pkey > LIMIT 100; > but here I test for repetitions using pkey and discard them > > -now if I get all repetitions or the last 100 have the same skey with > the second method, I use > select ... from tab WHERE skey=skey_last AND pkey>pkey_last > ORDER BY skey,pkey > LIMIT 100; > until I get an empty response, then I go back to the second method. if your distribution is such that those skeys that have > 100 records tend to have a lot more, you might have a higher limit for this case. > All queries are extremely fast with 6000000 records and it looks like > the few redundant or empty queries (but very fast) will not be a problem. > > What is your opinion about this (apart that it is a bit complex :) ?? looks fine gnari