Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Y1eWc-000318-C5 for pgsql-performance@arkaria.postgresql.org; Thu, 18 Dec 2014 17:06:06 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Y1eWb-00020Q-Qj for pgsql-performance@arkaria.postgresql.org; Thu, 18 Dec 2014 17:06:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Y1eWa-0001xu-Ef for pgsql-performance@postgresql.org; Thu, 18 Dec 2014 17:06:04 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Y1eWM-00066J-5s for pgsql-performance@postgresql.org; Thu, 18 Dec 2014 17:06:02 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id sBIH5j7H017791; Thu, 18 Dec 2014 12:05:45 -0500 From: Tom Lane To: Alessandro Ipe cc: pgsql-performance@postgresql.org, Torsten Zuehlsdorff Subject: Re: Excessive memory used for INSERT In-reply-to: <6053205.R7VxckQEVY@snow.oma.be> References: <2163931.4eVnXNjHa3@snow.oma.be> <4171.1418838543@sss.pgh.pa.us> <6645627.5dTte5MPLk@snow.oma.be> <6053205.R7VxckQEVY@snow.oma.be> Comments: In-reply-to Alessandro Ipe message dated "Thu, 18 Dec 2014 17:31:46 +0100" Date: Thu, 18 Dec 2014 12:05:45 -0500 Message-ID: <17790.1418922345@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org Alessandro Ipe writes: > Hi, > I tried also with an upsert function > CREATE FUNCTION upsert_func(sql_insert text, sql_update text) RETURNS void > LANGUAGE plpgsql > AS $$ > BEGIN > EXECUTE sql_update; > IF FOUND THEN > RETURN; > END IF; > BEGIN > EXECUTE sql_insert; > EXCEPTION WHEN OTHERS THEN > EXECUTE sql_update; > END; > RETURN; > END; > $$; > with the same result on the memory used... If you want to provide a self-contained test case, possibly we could look into it, but these fragmentary bits of what you're doing don't really constitute an investigatable problem statement. I will note that EXCEPTION blocks aren't terribly cheap, so if you're reaching the "EXECUTE sql_insert" a lot of times that might have something to do with it. regards, tom lane -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance