Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UMSu0-0006Xq-IX for pgsql-bugs@arkaria.postgresql.org; Mon, 01 Apr 2013 00:47:12 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UMSu0-0000Vz-1v for pgsql-bugs@arkaria.postgresql.org; Mon, 01 Apr 2013 00:47:12 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UMOPp-0006WX-0m for pgsql-bugs@postgresql.org; Sun, 31 Mar 2013 19:59:45 +0000 Received: from qmta02.westchester.pa.mail.comcast.net ([2001:558:fe14:43:76:96:62:24]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UMOPm-0002Wx-8P for pgsql-bugs@postgresql.org; Sun, 31 Mar 2013 19:59:43 +0000 Received: from omta10.westchester.pa.mail.comcast.net ([76.96.62.28]) by qmta02.westchester.pa.mail.comcast.net with comcast id JKjg1l0040cZkys51KzgYz; Sun, 31 Mar 2013 19:59:40 +0000 Received: from [192.168.1.165] ([98.216.109.209]) by omta10.westchester.pa.mail.comcast.net with comcast id JKzf1l0094X6qG23WKzfLa; Sun, 31 Mar 2013 19:59:39 +0000 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 6.3 \(1503\)) Subject: Re: BUG #8013: Memory leak From: Rae Stiening In-Reply-To: <12427.1364750172@sss.pgh.pa.us> Date: Sun, 31 Mar 2013 15:59:39 -0400 Cc: pgsql-bugs@postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <12427.1364750172@sss.pgh.pa.us> To: Tom Lane X-Mailer: Apple Mail (2.1503) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20121106; t=1364759980; bh=sDaTQszKUbzis1NkNnPAiQQlsSOLIWBJXcuZWHUDcis=; h=Received:Received:Content-Type:Mime-Version:Subject:From:Date: Message-Id:To; b=nr/NIisJUE13hqg1cIyNhnsKX7BoTW0BtY7NLfU3/wnWac6JNS5V4Scp+LhqxMrBB C6VW522pU9P+SRJuEKG6u58gjKbOlyStHhy59SADLCsbQK4bnQT+hdGT081jyCrECU jVmnNMEWAe8mEUDhGRSPLnfp90Yeimffr+DnDx28KPHy4nVuZMYaTvfJ+xaSVBek1J BjT3WzaCQ2VKx3up4lWSO9f4bCS/k6GO8Q+EjIxuA/PSgO/oswXpPgenbCYB8h0yCY ChURVJzZx3uIrrRhUJi/euoDqfoSojcDF3BrQOiwcIdgksmCRok3JeE1W/iviDA1I4 yrWAGxzbYvJuA== X-Pg-Spam-Score: -4.3 (----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org I found that by replacing the postgresql.conf file with the original that i= s present following an initdb the query ran without a memory problem. I lo= oked at the "bad" configuration file and couldn't see anything wrong with i= t. I regret that because of a typing error the bad file was accidentally d= eleted. I have subsequently been unable to reproduce the bad behavior. Af= ter editing the original file to be the same as what I had intended for the= erased file the query still ran without a problem. Memory usage topped ou= t at about 2.1 GB. Even setting work_mem and maintenance_work_mem to 30000= MB did not change the maximum memory usage during the query. Regards, Rae Stiening On Mar 31, 2013, at 1:16 PM, Tom Lane wrote: > stiening@comcast.net writes: >> The query: >> SELECT pts_key,count(*) >> FROM tm_tm_pairs GROUP BY pts_key HAVING count(*) !=3D1 ORDER BY >> pts_key >=20 >> Which is executed as: >> GroupAggregate (cost=3D108680937.80..119278286.60 rows=3D470993280 widt= h=3D4) >> Filter: (count(*) <> 1) >> -> Sort (cost=3D108680937.80..109858421.00 rows=3D470993280 width=3D= 4) >> Sort Key: pts_key >> -> Seq Scan on tm_tm_pairs (cost=3D0.00..8634876.80 rows=3D470= 993280 >> width=3D4) >=20 >> uses all available memory (32GB). pts_key is an integer and the table >> contains about 500 million rows. >=20 > That query plan doesn't look like it should produce any undue memory > consumption on the server side. How many distinct values of pts_key are > there, and what are you using to collect the query result client-side? > psql, for instance, would try to absorb the whole query result > in-memory, so there'd be a lot of memory consumed by psql if there are > a lot of pts_key values. (You can set FETCH_COUNT to alleviate that.) >=20 > A different line of thought is that you might have set work_mem to > an unreasonably large value --- the sort step will happily try to > consume work_mem worth of memory. >=20 > regards, tom lane --=20 Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs