Re: Paged Query

From: Misa Simic <misa(dot)simic(at)gmail(dot)com>
To: Hermann Matthes <hermann(dot)matthes(at)web(dot)de>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Paged Query
Date: 2012-07-06 13:43:58
Message-ID: CAH3i69=B7VPj0rkbuxv9TLEF6V0DjB2xzcEUkf8U7BYULCOBug@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Hi Hermann,

Well,

Not clear how you get rows for user without paging?

If it is some query:

SELECT columns FROM table WHERE UserHasPerimision(rowPK, userid)

Paging would be:

SELECT columns FROM table WHERE UserHasPerimision(rowPK, userid) LIMIT
NoOfRecords OFFSET page*NoOfRecords

Kind Regards,

Misa

2012/7/4 Hermann Matthes <hermann(dot)matthes(at)web(dot)de>

> I want to implement a "paged Query" feature, where the user can enter in a
> dialog, how much rows he want to see. After displaying the first page of
> rows, he can can push a button to display the next/previous page.
> On database level I could user "limit" to implement this feature. My
> problem now is, that the user is not permitted to view all rows. For every
> row a permission check is performed and if permission is granted, the row
> is added to the list of rows sent to the client.
> If for example the user has entered a page size of 50 and I use "limit 50"
> to only fetch 50 records, what should I do if he is only permitted to see
> 20 of these 50 records? There may be more records he can view.
> But if I don't use "limit", what happens if the query would return
> 5,000,000 rows? Would my result set contain 5,000,000 rows or would the
> performance of the database go down?
>
> Thanks in advance
> Hermann
>
> --
> Sent via pgsql-performance mailing list (pgsql-performance(at)postgresql(dot)**
> org <pgsql-performance(at)postgresql(dot)org>)
> To make changes to your subscription:
> http://www.postgresql.org/**mailpref/pgsql-performance<http://www.postgresql.org/mailpref/pgsql-performance>
>

In response to

  • Paged Query at 2012-07-04 12:25:28 from Hermann Matthes

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Stanislaw Pankevich 2012-07-06 13:45:53 Re: PostgreSQL db, 30 tables with number of rows < 100 (not huge) - the fastest way to clean each non-empty table and reset unique identifier column of empty ones.
Previous Message Albe Laurenz 2012-07-06 13:39:03 Re: PostgreSQL db, 30 tables with number of rows < 100 (not huge) - the fastest way to clean each non-empty table and reset unique identifier column of empty ones.