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 1pkAxG-0008Nd-Ro for pgsql-novice@arkaria.postgresql.org; Wed, 05 Apr 2023 21:46:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pkAxF-0002wy-Ot for pgsql-novice@arkaria.postgresql.org; Wed, 05 Apr 2023 21:46:09 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pkAxF-0002wp-GM for pgsql-novice@lists.postgresql.org; Wed, 05 Apr 2023 21:46:09 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pkAxC-0017w2-Si for pgsql-novice@postgresql.org; Wed, 05 Apr 2023 21:46:08 +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 335Lk4dv2174205; Wed, 5 Apr 2023 17:46:04 -0400 From: Tom Lane To: Roland Che cc: pgsql-novice Subject: Re: invalid memory alloc request size Error In-reply-to: References: Comments: In-reply-to Roland Che message dated "Wed, 05 Apr 2023 05:31:37 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2174203.1680731164.1@sss.pgh.pa.us> Date: Wed, 05 Apr 2023 17:46:04 -0400 Message-ID: <2174204.1680731164@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Roland Che writes: > I am having below error when our ANALYZE script runs. Our maintenance > work_mem is set to 128M but when this analyze script is ran, the > maintenance work_mem is set to session level at 2G but we are still > getting the error on some table columns. > ERROR: invalid memory alloc request size 8589934668. I am guessing that this happens when one of the pg_statistic entries for the column exceeds the datum size limit of 1GB. Do you have exceedingly wide values, and/or a very high default_statistics_target setting? > I saw a past dba had to disabled statistics by setting the statistics > value to 0 meaning stats will not be updated on such table columns. Dialing that setting back to zero is probably excessive. But if you don't want to back off default_statistics_target overall, you'll need to set a smaller value for your very wide column(s). I'm kind of surprised that this is an issue really, because ANALYZE tends to discriminate against storing very wide values at all. Can you provide more information about the column that's problematic? Do you have extended statistics of any sort on it? regards, tom lane