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 1umZmL-000JLW-HM for pgsql-hackers@arkaria.postgresql.org; Thu, 14 Aug 2025 15:22:09 +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 1umZmK-007Wtz-1V for pgsql-hackers@arkaria.postgresql.org; Thu, 14 Aug 2025 15:22:08 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1umZmJ-007WtW-ER for pgsql-hackers@lists.postgresql.org; Thu, 14 Aug 2025 15:22:07 +0000 Received: from mail-ot1-x32f.google.com ([2607:f8b0:4864:20::32f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1umZmG-000Z8J-2j for pgsql-hackers@lists.postgresql.org; Thu, 14 Aug 2025 15:22:06 +0000 Received: by mail-ot1-x32f.google.com with SMTP id 46e09a7af769-74382025891so360223a34.3 for ; Thu, 14 Aug 2025 08:22:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1755184924; x=1755789724; darn=lists.postgresql.org; h=content-transfer-encoding:content-disposition:mime-version :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=IAQ7u/FV5tVCZ64AsMgz9yRvEzxllkjL8OgUhUQmAsk=; b=KfJsY/bWLvkZO3Ec9AoB701dBs+/UgO/0lG04RAhM8eMpHcMzQRDLjPLnfDpoiI7QH oIZjDcTJPBMqbOIxV0voK/MD1qqJoDBusCLsypyeUjPJQg2FRvkeB3j+gzrSHjtQGGkB CTbkxOkurDG4fh+Txck/2YHRSvwcqMn2Lg2iFMiSww/2Njl0YZE+2+2h6loyWvczU2Rr bmI2p09Bx1IfMfOtBmp/SQXJAiz4Ijxct9acNGFksOgDZwek0HK723bDoblOjzlwGXHN PsMxCQlqbzHuMFWzMf6BnS4FFgGCkxTQEaEBhQXRVu/8V3+J6TxUYSKW83xf98J82d/h WTZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755184924; x=1755789724; h=content-transfer-encoding:content-disposition:mime-version :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IAQ7u/FV5tVCZ64AsMgz9yRvEzxllkjL8OgUhUQmAsk=; b=A5BNsyiUvE/1Y7iCHULGMd2SCvDpLk9R3OpJr7oHMrsKBo75J5C1Hs+UYOqYcE0NFq XENs4osd0q4oZXAHknkJuLf3hbbtoWjbooBqTzPi8qcJJ/dmHv0FUoJGGrcWz1EWtBn6 CCMm0UoOc4y5qwk4hwVY6UGJRgcO7uY3+UUrKaHVUDiFCRcsGa0EQMbEco/q3+JrAQ+y 7fNcsLu8HCZGg/TUbIouKAOcCXPnVhY5AAugQInHkn+QriDSXiMwG6zHCoEZ/VitG1e9 QzQzcRTzxk3aXaflbbe8SkvcuqWNTT3iqFlTvhcYLlFQ0aIDdNP1G7SQ/vNwOJ+SaJ0G loag== X-Forwarded-Encrypted: i=1; AJvYcCUmP5Nuorzp0lXy3/S7cKXrI6lpFw7SpzIb2pq9pAL1PCb2o8dSw3SpK7oMMGDbUVqMwDrghbyIg/cVZ48s@lists.postgresql.org X-Gm-Message-State: AOJu0YwGJ+FN5hgIN+e4tAkLSCT8Xfn0J5JxtmtGr7lxbx60SKw+OrIs 6KpUZn9LtRP9NRIgCTfrIDc5XALF0ZFFVCQ+FFm34lad1jZQrUjea8/7 X-Gm-Gg: ASbGnct3axk4Sgk8B5wGB5om1+CMfUIBasB9cvN4vVvaXqvx/fU2wMc3Epc1hvMy6vd AuAay1yFNnGc7wOebnxOzG1MmPqqT7dd7KZe7MV374/V7mrOXz3UxUk34OTye8Hl9Q5ININdvLS DdhPeQL+coEXUCJJNZZmqiHhVC0pM/ejd6Y9w0B0WstWQaLcignP0TrAy9eS6JvDJRAOxv5JiGB WLPCLP+LHYSDNnMAfpo1jQOQjzXHdyfw0p4tKVdG1F/yYiU0TUiOdXuwtG5aRukxTyPBoWf+sZO ITdN1uqK3kzfvKWjotY4RGwNIyo6YmId1GVHgBj/3bFs6xc7WuK2KyLcaJf1HJZu/ifYxc5zPQS 1BQmvRCqLqkcUBsgFQFMgGJdWz+iWk6WofPRiOmuVw+pnBDs6AJw3/xq0TZZHjSzaNQoRLRiYed zbrc6Nr5L94RH0 X-Google-Smtp-Source: AGHT+IGkeChFVV9UBfj6CD70qHav5w6rWcdiiFY2xLqZLlNjrAWMp6Nji2ZeKnOeIigJ5kUk/Npa1w== X-Received: by 2002:a05:6830:4490:b0:73c:bb23:3d38 with SMTP id 46e09a7af769-74382be328dmr2257796a34.20.1755184924368; Thu, 14 Aug 2025 08:22:04 -0700 (PDT) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-50ae9ccea59sm4427010173.96.2025.08.14.08.22.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 08:22:03 -0700 (PDT) Date: Thu, 14 Aug 2025 10:22:02 -0500 From: Nathan Bossart To: Tom Lane Cc: Nitin Motiani , Hannu Krosing , PostgreSQL Hackers Subject: pg_upgrade: transfer pg_largeobject_metadata's files when possible Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="DGpiUg7aQzWVm0yn" Content-Disposition: inline Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --DGpiUg7aQzWVm0yn Content-Type: text/plain; charset=us-ascii Content-Disposition: inline (new thread) On Fri, Jul 18, 2025 at 11:05:04AM -0500, Nathan Bossart wrote: > I'm cautiously optimistic that we can find some better gains for upgrades > from v16 and newer. That would involve dumping lo_create() commands for > all LOs with comments/seclabels, dumping the relevant pg_shdepend rows, and > then copying/linking the pg_largeobject_metadata files like we did prior to > v12. Here is a patch. For background, the reason this is limited to upgrades from v16 and newer is because the aclitem data type (needed by pg_largeobject_metadata.lomacl) changed its storage format in v16 (see commit 7b378237aa). Note that the patch is essentially a revert of commit 12a53c732c, but there are enough differences that it should be considered a fresh effort. Something I hadn't anticipated is that we need to take special care to transfer the relfilenode of pg_largeobject_metadata and its index, as was done for pg_largeobject in commits d498e052b4 and bbe08b8869. In fact, the majority of the patch is dedicated to that. My testing showed some decent, but not earth-shattering performance improvements from this patch. For upgrades with many large objects with NULL lomacl/lomowner columns, pg_upgrade was 50% faster. With non-NULL lomacl/lomowner, that dropped to 25%. When each large object had a comment, there was no change. I'm assuming that its rare to have lots of large objects with comments or security labels, so I don't see any need to expend energy trying to optimize that use-case. I am a bit concerned that we'll forget to add checks for new types of dependencies similar to comments and security labels. If we do, pg_upgrade should just fail to restore the schema, and fixing the code should be easy enough. Also, we'll need to remember to revisit this code if there's another storage format change for one of pg_largeobject_metadata's columns, but that seems unlikely to happen anytime soon. On the whole, I'm not too worried about either of these points. -- nathan --DGpiUg7aQzWVm0yn Content-Type: text/plain; charset=utf-8 Content-Disposition: attachment; filename=v1-0001-pg_upgrade-Transfer-pg_largeobject_metadata-s-fil.patch Content-Transfer-Encoding: 8bit