Re: best paging strategies for large datasets?

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: best paging strategies for large datasets?
Date: 2010-05-12 05:45:36
Message-ID: AANLkTimjdJBiX-z6KjDRLZgYvaksO6p4XmbBm6H5y3Ki@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello

2010/5/12 Louis-David Mitterrand <vindex+lists-pgsql-sql(at)apartia(dot)org>:
> Hi,
>
> I have a large dataset (page 1 at http://www.cruisefish.net/stat.md) and
> am in the process of developping a pager to let users leaf through it
> (30K rows).
>
> Ideally I'd like to know when requesting any 'page' of data where I am
> within the dataset: how many pages are available each way, etc.
>
> Of course that can be done by doing a count(*) query before requesting a
> limit/offset subset. But the main query is already quite slow, so I'd
> like to minimize them.

look on scrollable cursors.

see DECLARE CURSOR statement

Regards
Pavel Stehule

>
> But I am intrigued by window functions, especially the row_number() and
> ntile(int) ones.
>
> Adding "row_number() over (order by <reverse query>)" to my query will
> return the total number of rows in the first row, letting my deduce the
> number of pages remaining, etc. row_number() apparently adds very little
> cost to the main query.
>
> And ntile(buckets) seems nice too but I need the total row count for it
> to contain a 'page' number: ntile(row_count/page_size).
>
> What better "paging" strategies are out there?
>
> Thanks,
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message silly sad 2010-05-12 06:00:53 Re: [Trigger] Help needed with NEW.* and TG_TABLE_NAME
Previous Message Louis-David Mitterrand 2010-05-12 05:41:44 best paging strategies for large datasets?