Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 8633F632BE9 for ; Thu, 13 May 2010 10:28:51 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 58130-06 for ; Thu, 13 May 2010 13:28:44 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.magwerks.com (mail.magwerks.com [209.248.233.131]) by mail.postgresql.org (Postfix) with ESMTP id 23A91632967 for ; Thu, 13 May 2010 10:28:43 -0300 (ADT) Received: from [192.168.1.36] by mail.magwerks.com (GMS 15.01.3664/RS2750.00.1b502c7c) with ESMTP id gwzoeaaa for pgsql-sql@postgresql.org; Thu, 13 May 2010 09:28:41 -0400 Message-ID: <4BEBFE63.4050107@magwerks.com> Date: Thu, 13 May 2010 09:28:03 -0400 From: Justin Graf User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.9) Gecko/20100317 Lightning/1.0b1 Thunderbird/3.0.4 MIME-Version: 1.0 To: silly sad CC: pgsql-sql@postgresql.org Subject: Re: best paging strategies for large datasets? References: <20100512054144.GA8762@apartia.fr> <4BEBAC15.4030105@bankir.ru> <20100513074712.GB19779@apartia.fr> <4BEBBB3A.1060104@bankir.ru> In-Reply-To: <4BEBBB3A.1060104@bankir.ru> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-AntiSpam: Checked for restricted content by Gordano's AntiSpam Software X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.79 tagged_above=-5 required=5 tests=BAYES_50=0.8, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201005/63 X-Sequence-Number: 34111 On 5/13/2010 4:41 AM, silly sad wrote: > >>> First u count(*) the rows and select a requested page >>> returning to a client the count result bundled "with a page of rows" >>> >>> (1) client renders the acquired rows >>> (2)__memorize__ what part of the data he just got >>> (3) and stores the count result to calculate "the pager div" >>> >>> all the subsequent clicks on "the pager div" should not immediately >>> generate requests and decides if the request is needed. >> >> Yes, rendering the results throught ajax is a good idea, but one has to >> be careful not to expose one's LIMIT and OFFSET to the client, but only >> the "page" number. Or else the client could query the whole data set. A >> lot of "professional" web site have that hole. >> > > this is not a hole, it is only a matter of aesthetic > Silly Sad is right this is not a hole but a matter of aesthetics. To keep the code simple and limit the amount of things that have to be tracked with client session on the server, I pass the limit and offset to the client normally in a url/link. This also solves the problem if the users sessions expires, the information is lost meaning the user has to restart. Very annoying. So the urls look something like this www.mywebsit.com/index.php?module=getthedata&limit=10&offset=30&orderby=5 On the server set the these three data types to integer to block sql injection. I really don't care if the user sends a command to get all 10,000 records. If you block that, all that been accomplished is slowing down data harvesting and eating up even more resources, as the client/user will send ever more GETs to harvest data. Nothing has been accomplished. to keep the casual on looker for screwing with the url encode in base64. It keeps honest people honest but the hackers will pull that apart in a second. All legitimate Magwerks Corporation quotations are sent in a .PDF file attachment with a unique ID number generated by our proprietary quotation system. Quotations received via any other form of communication will not be honored. CONFIDENTIALITY NOTICE: This e-mail, including attachments, may contain legally privileged, confidential or other information proprietary to Magwerks Corporation and is intended solely for the use of the individual to whom it addresses. If the reader of this e-mail is not the intended recipient or authorized agent, the reader is hereby notified that any unauthorized viewing, dissemination, distribution or copying of this e-mail is strictly prohibited. If you have received this e-mail in error, please notify the sender by replying to this message and destroy all occurrences of this e-mail immediately. Thank you.