X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id D0C319DC88B for ; Wed, 1 Mar 2006 03:54:45 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 24781-06 for ; Wed, 1 Mar 2006 03:54:46 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from smtp-send.myrealbox.com (smtp-send.myrealbox.com [151.155.5.143]) by postgresql.org (Postfix) with ESMTP id D2B669DC831 for ; Wed, 1 Mar 2006 03:54:43 -0400 (AST) Received: from [172.16.1.180] grzm [61.197.227.146] by smtp-send.myrealbox.com with NetMail SMTP Agent $Revision: 1.6 $ on Linux; Tue, 28 Feb 2006 20:44:31 -0700 In-Reply-To: <1140790410.923941.261250@p10g2000cwp.googlegroups.com> References: <1140790410.923941.261250@p10g2000cwp.googlegroups.com> Mime-Version: 1.0 (Apple Message framework v746.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Cc: pgsql-performance@postgresql.org Content-Transfer-Encoding: 7bit From: Michael Glaesemann Subject: Re: nested query on last n rows of huge table Date: Wed, 1 Mar 2006 12:44:25 +0900 To: "jcfischer" X-Mailer: Apple Mail (2.746.2) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=1.099 required=5 tests=[AWL=-0.233, RCVD_IN_BL_SPAMCOP_NET=1.332] X-Spam-Score: 1.099 X-Spam-Level: * X-Archive-Number: 200603/2 X-Sequence-Number: 17439 On Feb 24, 2006, at 23:13 , jcfischer wrote: > Is there a way to limit the expensive query to only those last 1000 > (or > whatever) results? > > I have tried to nest SELECTS but my SQL-fu is to limited to get > anything through the SQL processor :-) The basics of a subquery are: SELECT FROM ( SELECT * FROM table ORDER eventtime DESC LIMIT 1000 ) as most_recent_1000 Don't know enough about the other parts, but hopefully this can get you started. :) Michael Glaesemann grzm myrealbox com