Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id C42AE9FC3CF for ; Fri, 18 May 2007 13:42:16 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 74139-03 for ; Fri, 18 May 2007 13:42:12 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from cassarossa.samfundet.no (cassarossa.samfundet.no [129.241.93.19]) by postgresql.org (Postfix) with ESMTP id 333279FC3D0 for ; Fri, 18 May 2007 13:42:12 -0300 (ADT) Received: from trofast.ipv6.sesse.net ([2001:700:300:1803:20e:cff:fe36:a766] helo=trofast.sesse.net) by cassarossa.samfundet.no with esmtp (Exim 4.50) id 1Hp5Ws-00071h-HQ; Fri, 18 May 2007 18:42:10 +0200 Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) id 1Hp5Ws-00040h-00; Fri, 18 May 2007 18:42:10 +0200 Date: Fri, 18 May 2007 18:42:10 +0200 From: "Steinar H. Gunderson" To: Abu Mushayeed Cc: pgsql-performance@postgresql.org Subject: Re: CPU Intensive query Message-ID: <20070518164210.GA15372@uio.no> Mail-Followup-To: Abu Mushayeed , pgsql-performance@postgresql.org References: <877956.83201.qm@web57112.mail.re3.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <877956.83201.qm@web57112.mail.re3.yahoo.com> X-Operating-System: Linux 2.6.20.4 on a x86_64 X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ User-Agent: Mutt/1.5.13 (2006-08-11) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200705/326 X-Sequence-Number: 24716 On Fri, May 18, 2007 at 09:02:52AM -0700, Abu Mushayeed wrote: > I have an interesting problem. I have the following query that ran ok on > Monday and Tuesday and it has been running ok since I have been at this > job. I have seen it to be IO intensive, but since Wednesday it has become > CPU intensive. Database wise fresh data has been put into the tables, > vacuumed & analyzed, no other parameter has been modified. What Postgres version is this? > The query is as follows and it's explain plan is also attached: Normally EXPLAIN ANALYZE data would be much better than EXPLAIN, but if the query indeed does not finish, it's not going to help much. > set enable_nestloop = off; What's the rationale for this? > HashAggregate (cost=152555.97..152567.32 rows=267 width=162) 152000 disk page fetches is a bit, but it shouldn't take 24 hours. There's probably misestimation involved at some point here. Does it really return 267 rows, or many more? /* Steinar */ -- Homepage: http://www.sesse.net/