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 1oxAcj-0005u6-Qs for pgsql-admin@arkaria.postgresql.org; Mon, 21 Nov 2022 17:30:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oxAci-0000o4-CH for pgsql-admin@arkaria.postgresql.org; Mon, 21 Nov 2022 17:30:24 +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 1oxAci-0000no-1B for pgsql-admin@lists.postgresql.org; Mon, 21 Nov 2022 17:30:24 +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 1oxAcf-0006eS-QX for pgsql-admin@lists.postgresql.org; Mon, 21 Nov 2022 17:30:22 +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 2ALHUKdr3215517; Mon, 21 Nov 2022 12:30:20 -0500 From: Tom Lane To: Massimo Ortensi cc: pgsql-admin@lists.postgresql.org Subject: Re: Out of memory error during pg_upgrade in big DB with large objects In-reply-to: <1ox9nq-005Lel-UF@unimaticaspa.it> References: <1ox9nq-005Lel-UF@unimaticaspa.it> Comments: In-reply-to Massimo Ortensi message dated "Mon, 21 Nov 2022 17:37:50 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3215515.1669051820.1@sss.pgh.pa.us> Date: Mon, 21 Nov 2022 12:30:20 -0500 Message-ID: <3215516.1669051820@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Massimo Ortensi writes: > I'm trying to upgrade a huge DB from postgres 10 to 14 > This cluster is 70+ TB, with one database having more than 2 billion > records in pg_largeobject > I'm trying pg_upgrade in hard link mode, but the dump of databas schema > phase always fails with > pg_dump: error: query failed: out of memory for query result > pg_dump: error: query was: SELECT l.oid, (SELECT rolname FROM > pg_catalog.pg_roles WHERE oid = l.lomowner) AS rolname, (SELECT > pg_catalog.array_agg(acl ORDER BY row_n) FROM (SELECT acl, row_n FROM FWIW, this query was rewritten pretty substantially in v15. It's still going to produce a row per large object, but it should be a lot narrower because most of the ACL-wrangling now happens somewhere else. I don't know if migrating to v15 instead of v14 is an option for you, and I can't promise that that'd be enough savings to fix it anyway. But it's something to think about. regards, tom lane