Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 179711EB83EA for ; Thu, 23 Feb 2012 12:18:34 -0400 (AST) Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1S0bNH-0001Qn-Cz for pgsql-bugs@postgresql.org; Thu, 23 Feb 2012 16:18:33 +0000 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 q1NGIFrO014926; Thu, 23 Feb 2012 11:18:16 -0500 (EST) To: Marti Raudsepp cc: kouber@saparev.com, pgsql-bugs@postgresql.org Subject: Re: BUG #6483: Rows being evaluated, although being outside the LIMIT / OFFSET boundaries In-reply-to: References: <25657.1329946832@sss.pgh.pa.us> Comments: In-reply-to Marti Raudsepp message dated "Thu, 23 Feb 2012 00:05:22 +0200" Date: Thu, 23 Feb 2012 11:18:15 -0500 Message-ID: <14925.1330013895@sss.pgh.pa.us> From: Tom Lane X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201202/179 X-Sequence-Number: 32522 Marti Raudsepp writes: > AFAICT, the model in the documentation suggests that the SELECT fields > are evaluated for all matching rows in indeterminate order, before > ORDER BY is applied and before the result set is sliced by > OFFSET/LIMIT. That is in fact the case if you have a query plan that involves a Sort node followed by Limit. We have some optimizations that avoid the need for an explicit sort, but it would be pretty hard to write a specification for exactly when unretrieved rows will not be evaluated. regards, tom lane