Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 7548F9FB3F3 for ; Sat, 17 Feb 2007 11:24:52 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 96904-08 for ; Sat, 17 Feb 2007 11:24:49 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from main2.mycybernet.net (main2.mycybernet.net [209.222.63.140]) by postgresql.org (Postfix) with ESMTP id A6CA19FB3E2 for ; Sat, 17 Feb 2007 11:24:49 -0400 (AST) Received: from 227-54-222-209.mycybernet.net ([209.222.54.227] helo=phlogiston.dydns.org) by main2.mycybernet.net with esmtp (Exim 4.62) (envelope-from ) id 1HIRda-0006ZK-TV for pgsql-sql@postgresql.org; Sat, 17 Feb 2007 10:38:11 -0500 Received: by phlogiston.dydns.org (Postfix, from userid 1000) id 31ED14050; Sat, 17 Feb 2007 10:24:34 -0500 (EST) Date: Sat, 17 Feb 2007 10:24:34 -0500 From: Andrew Sullivan To: pgsql-sql@postgresql.org Subject: Re: ordering of selected rows from an ordered subselect Message-ID: <20070217152434.GA3623@phlogiston.dyndns.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.9i X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.635 tagged_above=0 required=5 tests=AWL, BAYES_60, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200702/183 X-Sequence-Number: 27517 On Sat, Feb 17, 2007 at 03:02:06PM +0530, Rajesh Kumar Mallah wrote: > > select id , name , expensive_func(name) from > ( select id , name from tab order by c1 desc limit 15) as foo ; > > is it guaranteed that the final result is order by c1 ? No, because expensive_func(name) might do something that alters it, no? All things considered, it's a pretty good _bet_ it will be ordered as you wish, though. A -- Andrew Sullivan | ajs@crankycanuck.ca The whole tendency of modern prose is away from concreteness. --George Orwell