Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 2AE8012822DA for ; Wed, 22 Feb 2012 17:40:49 -0400 (AST) Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1S0Jva-0005mR-OO for pgsql-bugs@postgresql.org; Wed, 22 Feb 2012 21:40:48 +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 q1MLeWVF025658; Wed, 22 Feb 2012 16:40:32 -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: Comments: In-reply-to Marti Raudsepp message dated "Wed, 22 Feb 2012 23:13:03 +0200" Date: Wed, 22 Feb 2012 16:40:32 -0500 Message-ID: <25657.1329946832@sss.pgh.pa.us> From: Tom Lane X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201202/172 X-Sequence-Number: 32515 Marti Raudsepp writes: > According to this model, evaluating SELECT clause fields for *all* > found rows is done in step 5, whereas LIMIT/OFFSET are only applied > later at step 9. So we're already bending the rules here (in general > we don't do such optimizations around volatile functions). The worst > thing is that it's inconsistent -- the LIMIT gets applied when > computing the SELECT list, but OFFSET doesn't. On what grounds do you say that? LIMIT and OFFSET are practically the same thing internally, and are certainly applied in the same way. regards, tom lane