Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id E5086B5D801 for ; Fri, 30 Sep 2011 15:56:51 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 41801-01 for ; Fri, 30 Sep 2011 18:56:44 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 1833FB5D803 for ; Fri, 30 Sep 2011 15:56:43 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p8UIugCX011061; Fri, 30 Sep 2011 14:56:42 -0400 (EDT) To: Josh Berkus cc: postgres performance list Subject: Re: Shortcutting too-large offsets? In-reply-to: <4E860E09.7090107@agliodbs.com> References: <4E850FC0.509@agliodbs.com> <6843.1317393410@sss.pgh.pa.us> <4E860E09.7090107@agliodbs.com> Comments: In-reply-to Josh Berkus message dated "Fri, 30 Sep 2011 11:44:25 -0700" Date: Fri, 30 Sep 2011 14:56:42 -0400 Message-ID: <11059.1317409002@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.404 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-0.504 X-Spam-Level: X-Archive-Number: 201109/442 X-Sequence-Number: 45218 Josh Berkus writes: >> In principle, yeah, we could make it do that, but it seems like a likely >> source of maintenance headaches. This example is not exactly compelling >> enough to make me want to do it. Large OFFSETs are always going to be >> problematic from a performance standpoint, and the fact that we could >> short-circuit this one corner case isn't really going to make them much >> more usable. > It's not that uncommon of a corner case though; it's one which happens > all the time in webapps which paginate. People just have to ask for a > page after the end. It's really a question of how simple the code to > make the optimization would be; if it would be a 5-line patch, then it's > worth it; if it would be a 110-line refactor, no. No, it's really a question of whether it's worth any lines at all, and I remain unconvinced. If someone asks for the last page, or any page near the end, it'll take just about the same amount of time as asking for a page past the end. So any app like this is going to have sucky performance, and kluging the corner case isn't going to help much. regards, tom lane