X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id B02B0D1B4E1 for ; Thu, 13 Nov 2003 05:21:22 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 54620-09 for ; Thu, 13 Nov 2003 01:20:52 -0400 (AST) Received: from davinci.ethosmedia.com (server228.ethosmedia.com [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id B6A91D1B507 for ; Thu, 13 Nov 2003 01:20:51 -0400 (AST) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3908779; Wed, 12 Nov 2003 21:21:35 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: Christopher Kings-Lynne , PostgreSQL Performance Subject: Re: Query question Date: Wed, 12 Nov 2003 21:20:28 -0800 User-Agent: KMail/1.4.3 References: <3FB303E9.20903@familyhealth.com.au> In-Reply-To: <3FB303E9.20903@familyhealth.com.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200311122120.28882.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200311/82 X-Sequence-Number: 4642 Chris, > SELECT * FROM (arbitrary subquery) AS sub ORDER BY 1,3; > > Now, this all works fine, but I want to know if this is efficient or not. > > Does doing a select of a select cause serious performance degradation? It would be better if you could strip out the inner sort, but I can understand why that might not be possible in all cases. The only thing you're adding to the query is a second SORT step, so it shouldn't require any more time/memory than the query's first SORT did. -- Josh Berkus Aglio Database Solutions San Francisco