X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DA4DA32A1B4 for ; Thu, 30 Sep 2004 16:02:04 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 29311-04 for ; Thu, 30 Sep 2004 15:02:03 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 997F232A1AC for ; Thu, 30 Sep 2004 16:02:02 +0100 (BST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id i8UF21Dl016698; Thu, 30 Sep 2004 11:02:01 -0400 (EDT) To: "Merlin Moncure" Cc: "Stephan Szabo" , pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org Subject: Re: spurious function execution in prepared statements. In-reply-to: <6EE64EF3AB31D5448D0007DD34EEB3412A74DF@Herge.rcsinc.local> References: <6EE64EF3AB31D5448D0007DD34EEB3412A74DF@Herge.rcsinc.local> Comments: In-reply-to "Merlin Moncure" message dated "Thu, 30 Sep 2004 10:58:34 -0400" Date: Thu, 30 Sep 2004 11:02:01 -0400 Message-ID: <16697.1096556521@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200409/342 X-Sequence-Number: 8470 "Merlin Moncure" writes: > Here is the actual query: > select lock_cuid(id), * > ... > order by wcl_vin_no, wcl_claim_no, id > limit 1 Looks like Stephan made the right guess. Logically the LIMIT executes after the ORDER BY, so the sorted result has to be formed completely. The fact that we are able to optimize this in some cases does not represent a promise that we can do it in all cases. Ergo, it's not a bug. regards, tom lane