Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1seICq-005nKS-OO for pgsql-bugs@arkaria.postgresql.org; Wed, 14 Aug 2024 17:54:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1seICo-00BvtP-JG for pgsql-bugs@arkaria.postgresql.org; Wed, 14 Aug 2024 17:54:42 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1seICo-00BvtG-1S for pgsql-bugs@lists.postgresql.org; Wed, 14 Aug 2024 17:54:42 +0000 Received: from relay8-d.mail.gandi.net ([2001:4b98:dc4:8::228]) by magus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1seICl-004qrR-EI for pgsql-bugs@lists.postgresql.org; Wed, 14 Aug 2024 17:54:41 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 6939A1BF203; Wed, 14 Aug 2024 17:54:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vondra.me; s=gm1; t=1723658074; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Cn2Mf714t9fJKx1F/PeZ+uhxiZDUcfYqiChEkFCK8Xc=; b=BX5H7R+G2nNhboAH1lcnEaNOsNZ2TbGWdHGiJ49g/O5b+UN29/ILNkfYxydEQcTte8ALth XJkqL2iZgyCUHb4Fo4g93KWt/xkyCC6FyA512A7fE+GWproP/5xOiI+FKpCKmfvTcITPFD sQnKk/79rgdMXxuYKGtgKR69biQGRlav6suhzads9uiTSe+mc/r2pl9xFMTQkPCXbxhTRM XYMOZjIwiHpYHhniILHmTLESg/JnFtdJ8g24oQ2UicXy/OgCmoCqYVQTVOh5BKVXS3XMXm /tncFw4sHNihjevIKc1DehWXXR6PmRLoXXFRxR08YFIEfm1i+9SDZedNwtiV+A== Message-ID: <210ebcb9-4bf0-45c5-99bc-c0a2c8b77df4@vondra.me> Date: Wed, 14 Aug 2024 19:54:32 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Certain options in pg_upgrade don't seem to work. To: DBA , "pgsql-bugs@lists.postgresql.org" References: <20240814014150.15B2710705F@wsmtpa1.ecounterp.com> Content-Language: en-US From: Tomas Vondra In-Reply-To: <20240814014150.15B2710705F@wsmtpa1.ecounterp.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-GND-Sasl: tomas@vondra.me List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 8/14/24 03:41, DBA wrote: > Hello, I'm inquiring because --j option don't seem to be working > properly in pg_upgrade. > > > *1. A description of what you are trying to achieve and what results you > expect : * > > > We took to much time to upgrade postgresql with pg_upgrade. > > > So we have tested with --j option in pg_upgrade by below command  > > > *time PGPASSWORD='1q2w3e4r' nohup /usr/lib/postgresql/16/bin/pg_upgrade > -b /usr/lib/postgresql/15/bin/ -B /usr/lib/postgresql/16/bin/ -d > /data/PG15 -D /data/PG16 -k -j 16 -U ecount_own > /data/tmp4/upgrade.log &* > > > It took 520 minutes to upgrade and we used -j option to make pg_upgrade > use multiple CPU processor but it didn't use them. (Only use single > processor)  > > (It took the same amount of time as when tested without --j option.) > > > Is it normal not to use multiple cpu cores even with the --j option? > > > The docs says that you use multi-processors for restoring. > > > *note.)* We have about 80 partition tables and each partition table has > 9000 children tables. > > >        I think it could be affected by the number of partition tables. > Very likely. The thing is, pg_upgrade does multiple tasks, and only some of those are parallelized - the pg_upgrade [1] docs say: The --jobs option allows multiple CPU cores to be used for copying/linking of files and to dump and restore database schemas in parallel; a good place to start is the maximum of the number of CPU cores and tablespaces. This option can dramatically reduce the time to upgrade a multi-database server running on a multiprocessor machine. So it's only the "linking" of files that's done using multiple jobs: ... Linking user relation files ok ... But with 80 partitioned tables, and 9000 partitions for each, the most expensive step is likely dump/restore of the schema. And those are not parallelized - it always happens in a single process. You can confirm this by watching the pg_upgrade output, to see which steps take most of the time. regards -- Tomas Vondra