X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 8A44ED1E9D7 for ; Wed, 21 Jan 2004 19:03:07 +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 14427-01 for ; Wed, 21 Jan 2004 15:02:37 -0400 (AST) Received: from wolff.to (wolff.to [66.93.249.74]) by svr1.postgresql.org (Postfix) with SMTP id DD2D4D1EA7C for ; Wed, 21 Jan 2004 14:35:56 -0400 (AST) Received: (qmail 4290 invoked by uid 500); 21 Jan 2004 18:36:56 -0000 Date: Wed, 21 Jan 2004 12:36:56 -0600 From: Bruno Wolff III To: Ron St-Pierre Cc: pgsql-performance@postgresql.org Subject: Re: ORDER BY and LIMIT with SubSelects Message-ID: <20040121183656.GC11684@wolff.to> Mail-Followup-To: Ron St-Pierre , pgsql-performance@postgresql.org References: <400EB45A.40309@syscor.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <400EB45A.40309@syscor.com> User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/211 X-Sequence-Number: 5385 On Wed, Jan 21, 2004 at 09:18:18 -0800, Ron St-Pierre wrote: > > My question is in regards to steps 2 and 3 above. Is there some way that > I can combine both steps into one to save some time? TIP 4: Don't 'kill -9' the postmaster SELECT SS.* FROM (SELECT DISTINCT ON (nonUniqField) first, second, third, cost, payDate, nonUniqField FROM histdata WHERE userID = 19048 AND cost IS NOT NULL ORDER BY nonUniqField, payDate DESC LIMIT 200 ) SS ORDER BY payDate;