Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 0A796B5DBCA for ; Fri, 30 Sep 2011 11:37:01 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 04148-09 for ; Fri, 30 Sep 2011 14:36:54 +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 7FBB2B5DBC7 for ; Fri, 30 Sep 2011 11:36:54 -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 p8UEapGm006844; Fri, 30 Sep 2011 10:36:51 -0400 (EDT) To: Josh Berkus cc: postgres performance list Subject: Re: Shortcutting too-large offsets? In-reply-to: <4E850FC0.509@agliodbs.com> References: <4E850FC0.509@agliodbs.com> Comments: In-reply-to Josh Berkus message dated "Thu, 29 Sep 2011 17:39:28 -0700" Date: Fri, 30 Sep 2011 10:36:50 -0400 Message-ID: <6843.1317393410@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/436 X-Sequence-Number: 45212 Josh Berkus writes: > Here's a case which it seems like we ought to be able to optimize for: > [ offset skips all the output of a sort node ] > Is there some non-obvious reason which would make this kind of > optimization difficult? Doesn't the executor know at that point how > many rows it has? 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. regards, tom lane