Home > Archive > PostgreSQL SQL > May 2005 > Re: Does Postgresql have a similar pseudo-column "ROWNUM" as









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Does Postgresql have a similar pseudo-column "ROWNUM" as
Ragnar Hafstaš

2005-05-18, 3:24 am

On Tue, 2005-05-17 at 23:16 -0300, Alain wrote:
>
> Ragnar Hafstaš escreveu:
[color=darkred]
> 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



---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com