Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id CD1C71337B49 for ; Sat, 16 Apr 2011 04:21:38 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 99595-06 for ; Sat, 16 Apr 2011 07:21:31 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.catalyst.net.nz (bertrand.catalyst.net.nz [202.78.240.40]) by mail.postgresql.org (Postfix) with ESMTP id DD7FD1336FA7 for ; Sat, 16 Apr 2011 04:21:30 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by mail.catalyst.net.nz (Postfix) with ESMTP id DDDEC321AE; Sat, 16 Apr 2011 19:21:29 +1200 (NZST) X-Virus-Scanned: Debian amavisd-new at catalyst.net.nz Received: from mail.catalyst.net.nz ([127.0.0.1]) by localhost (bertrand.catalyst.net.nz [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id p5Z0pRwbJ3Bs; Sat, 16 Apr 2011 19:21:29 +1200 (NZST) Received: from [192.168.1.11] (122-60-64-230.jetstream.xtra.co.nz [122.60.64.230]) (Authenticated sender: mark.kirkwood) by mail.catalyst.net.nz (Postfix) with ESMTPSA id 21E3B32196; Sat, 16 Apr 2011 19:21:29 +1200 (NZST) Message-ID: <4DA94378.5030600@catalyst.net.nz> Date: Sat, 16 Apr 2011 19:21:28 +1200 From: Mark Kirkwood User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.14) Gecko/20110223 Thunderbird/3.1.8 MIME-Version: 1.0 To: Tom Lane CC: pgsql-bugs@postgresql.org Subject: Re: Massive memory use for star query References: <4DA7CB25.5040102@catalyst.net.nz> <25522.1302885781@sss.pgh.pa.us> In-Reply-To: <25522.1302885781@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201104/122 X-Sequence-Number: 30041 On 16/04/11 04:43, Tom Lane wrote: > Mark Kirkwood writes: >> I've recently seen examples of star-like queries using vast amounts of >> memory in one of our production systems. Here's a simplified example >> using synthetic data (see attached to generate if desired): >> SET geqo_threshold = 14; >> SET from_collapse_limit = 14; >> SET join_collapse_limit = 14; > Well, if you're going to do the above, you should be expecting the > planner to eat a lot of memory. There is a reason why the default > values of those parameters are significantly lower than that ... > Ok - so with the settings at their defaults geqo chooses a semi-random plan, and at least one of those (for the production variant of this query anyway) eat massive (>100G) amounts of temp space - not really a suitable outcome either. I guess you have answered my first question - i.e yes this should eat massive amount of ram as written - however are you sure there is no memory leaking going on here? regards Mark