Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mplD5-0001Rj-Dh for pgsql-performance@arkaria.postgresql.org; Wed, 24 Nov 2021 05:52:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mplD4-0005RV-AK for pgsql-performance@arkaria.postgresql.org; Wed, 24 Nov 2021 05:52:46 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mplD4-0005RM-0Y for pgsql-performance@lists.postgresql.org; Wed, 24 Nov 2021 05:52:46 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mplCz-0002vg-GR for pgsql-performance@lists.postgresql.org; Wed, 24 Nov 2021 05:52:45 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 1AO5qc9s097241; Wed, 24 Nov 2021 00:52:38 -0500 From: Tom Lane To: aditya desai cc: Pgsql Performance Subject: Re: Out of memory error In-reply-to: References: Comments: In-reply-to aditya desai message dated "Wed, 24 Nov 2021 10:57:37 +0530" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <97239.1637733158.1@sss.pgh.pa.us> Date: Wed, 24 Nov 2021 00:52:38 -0500 Message-ID: <97240.1637733158@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk aditya desai writes: > In a trigger function I am creating a temp table . When an update on a > table is executed for say 10k rows. I get the below error. > ERROR: out of shared memory > HINT:You might need to increase max_locks_per_transaction > CONTEXT: SQL Statement "created temp table changedinfo(colName > varchar(100), oldValue varchar(4000), newValue varchar(4000) [ raised eyebrow ... ] If you are concerned about performance, I'd start by not creating a temp table per row of the outer update. That's costing probably 100x to 1000x as much as the row update itself. regards, tom lane