Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id F05F2B5D91F for ; Fri, 13 May 2011 05:28:25 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 69308-06 for ; Fri, 13 May 2011 08:28:19 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.anarazel.de (mail.anarazel.de [217.115.131.40]) by mail.postgresql.org (Postfix) with ESMTP id 0C2ABB5D8C5 for ; Fri, 13 May 2011 05:28:18 -0300 (ADT) Received: from intern.anarazel.de (unknown [89.204.153.103]) (Authenticated sender: andres@anarazel.de) by mail.anarazel.de (Postfix) with ESMTPA id 3D003448003; Fri, 13 May 2011 10:41:11 +0200 (CEST) From: Andres Freund To: pgsql-performance@postgresql.org Subject: Re: setting configuration values inside a stored proc Date: Fri, 13 May 2011 10:28:15 +0200 User-Agent: Kmail Cc: Samuel Gendler References: In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <201105131028.15694.andres@anarazel.de> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.14 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_IN_SORBS_WEB=0.77, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201105/199 X-Sequence-Number: 43708 Hi, On Friday, May 13, 2011 01:10:19 AM Samuel Gendler wrote: > I've got a stored proc that constructs some aggregation queries as strings > and then executes them. I'd like to be able to increase work_mem before > running those queries. If I set a new value for work_mem within the stored > proc prior to executing my query string, will that actually have an impact > on the query or is work_mem basically a constant once the outer statement > that calls the stored proc has begun? I'd just test, but it will take > hours for me to grab a copy of production data and import into a new db > host for testing. I've already started that process, but I'm betting I'll > have an answer by the time it completes. It's just the difference between > modifying the application which calls the procs (and doing a full software > release in order to do so or else waiting a month to go in the next > release) vs modifying the procs themselves, which requires only db a > update. I would suggest doing ALTER FUNCTION blub(blarg) SET work_mem = '512MB'; Andres