Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 6B1581BD2591 for ; Wed, 4 Jul 2012 09:25:48 -0300 (ADT) Received: from mout.web.de ([212.227.17.11]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SmOeP-0004ax-LE for pgsql-performance@postgresql.org; Wed, 04 Jul 2012 12:25:47 +0000 Received: from [192.168.178.20] ([93.104.134.8]) by smtp.web.de (mrweb102) with ESMTPSA (Nemesis) id 0MeSKR-1SSNU30K4N-00Q3lB for ; Wed, 04 Jul 2012 14:25:32 +0200 Message-ID: <4FF43638.5080301@web.de> Date: Wed, 04 Jul 2012 14:25:28 +0200 From: Hermann Matthes User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Paged Query Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:ks2C0kSXKqj+KaOXgtSYXc9lzTt+rK8dM29WxPZF1Xb WB+KyMkMtSyt8BRt+ALYUNeAopJ+3xSx/K1IckuS+7rl3VmIEa Uv1Bvgc6BUsEtUAIddnk7qss7xdYleo/Jd8a6hUYkZVK/1GREI IYCyJccaZvQriF/KIyJcnNt3mwNvGE+EdHDys0DIJVs+vQQXWd YYDxFkzcwJcH8qW/yElTA== X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201207/49 X-Sequence-Number: 47230 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