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.96) (envelope-from ) id 1wC5OP-001eJ3-2F for pgsql-hackers@arkaria.postgresql.org; Mon, 13 Apr 2026 00:43:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wC5ON-003gQw-32 for pgsql-hackers@arkaria.postgresql.org; Mon, 13 Apr 2026 00:43:08 +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.96) (envelope-from ) id 1wC5ON-003gQo-27 for pgsql-hackers@lists.postgresql.org; Mon, 13 Apr 2026 00:43:08 +0000 Received: from fout-b8-smtp.messagingengine.com ([202.12.124.151]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wC5OM-00000000kgo-1uHT for pgsql-hackers@lists.postgresql.org; Mon, 13 Apr 2026 00:43:08 +0000 Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfout.stl.internal (Postfix) with ESMTP id 8CC2C1D00089; Sun, 12 Apr 2026 20:43:03 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Sun, 12 Apr 2026 20:43:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1776040983; x=1776127383; bh=FPQ/Ya5zKr NBUwC2XIs9sW35xxNEtZrblvqcA0nzCU0=; b=je/zNVu0GYQf3ncrI7xAzW3Ztw GotAFeoSCaCkmeeIahCwUNnO9PvwYSIoSAwkWWY0bnwwp5KVkOAoiFspFFr57doD f3MycTabpUtyptkgoh8KmSxnJBjwiQNds5Ke+kPLqBzdMXWUeUCxYcDgNHD1Hsc9 1ZF5LIXEAXxcBk15CNbMjCTYLSwQGRz0ZrfMIITZjgAMuYFRj4bAqMYRZmFrmwDP UlCc6hi58bBWjB+i76Zo+ocePgcLsoyL4h85sG8XwNGGJd1KIzDb0LWGCDRPadwT NksQ8y/42edxQLi0TOgFo2AT1UoYWFZQeRIqeJpUgVQ6BtYUGaoCFEfyLU+Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1776040983; x=1776127383; bh=FPQ/Ya5zKrNBUwC2XIs9sW35xxNEtZrblvq cA0nzCU0=; b=Lmtl0VAZOp3PE/ogdwVFWHTQ6tYW0Wp/5cwudQrlbhitzt7jgaE CdHpLStNLsKIZajFdzA9Kg6G2sVPbQZCMy0C0rM0cXn8w4PYvG9Jze2cRK1bBUYd P7Swpip9BPy34nE51umi/Zbd7g0yCoxCrqzKApmyx+AR9/wGPUy19wNkqg4+4dIl 5Hmy29fACs2ayfZ5ygCElnqllk8pfMYoUnPd8FON1RjI2EL3NBlWTMgbyvBuK39L JFf1jIICOe/BqpAdF0HHLVwPP4oXroA4/U6lzNR3LQYrwQorDGeWQgXDfJiX7y0F f16/S0M4yos4gMWYytDuZgISbiO6xNQhR4w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdefieektdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecufghrlhcuvffnffculdejtddmnecujfgurhepfffhvfevuf fkfhggtggujgesghdtreertddtvdenucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgv rhcuoehmihgthhgrvghlsehprghquhhivghrrdighiiiqeenucggtffrrghtthgvrhhnpe etleeifedufffhhfdtteelgeeggeffhfekueevteeigfduudevudetgfegiedvjeenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvg hlsehprghquhhivghrrdighiiipdhnsggprhgtphhtthhopedvpdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopegthhgrrhhshigrmhesghhmrghilhdrtghomhdprhgtphhtth hopehpghhsqhhlqdhhrggtkhgvrhhssehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhr gh X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 12 Apr 2026 20:43:02 -0400 (EDT) Date: Mon, 13 Apr 2026 09:43:00 +0900 From: Michael Paquier To: CharSyam Cc: pgsql-hackers@lists.postgresql.org Subject: Re: [PATCH] Reduce pg_class scans in GRANT/REVOKE ON ALL TABLES IN SCHEMA Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="MFlxhIsZe/3eGhB7" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --MFlxhIsZe/3eGhB7 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Apr 12, 2026 at 04:22:24PM +0900, CharSyam wrote: > Benchmark > --------- > This is a targeted micro-optimization, not a dramatic speedup. > With 10,000 tables in a single schema (pg_class ~10,452 rows), > running GRANT/REVOKE SELECT ON ALL TABLES IN SCHEMA in a loop > (6 iterations, first dropped as warmup), I measured a consistent > ~15% reduction in end-to-end time: >=20 > baseline patched delta > GRANT (avg) 88.2 ms 75.9 ms -14% > REVOKE (avg) 134.9 ms 115.7 ms -14% I am pretty sure that there are users with millions of relations in a single schema that could benefit from that. At least that would not be surprising with partitioning these days, and foreign tables. What kind of numbers do you get if you bump up the number of digits for these tests. Let's say a comparison based on a few million relations at least? The change you are proposing looks simple enough, quickly skimming through the patch. There may be more optimizations doable here, I have not looked at that, still I tend to like such micro-optimization proposals as they provide a silent benefit. -- Michael --MFlxhIsZe/3eGhB7 Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmncPBQACgkQnvQgOdby QH0FRRAAlKoe/U2dgVhg6vlOThxFqhsg8V43tL6DjPx5QnjfjKpQYgs3wMKcRaPk 0nvvfWgKXva/cefD/RZ9aeSp6fwZtf0La8OwKdQd1w7j1EA0xxJhXtQjQ2dCLmzE VBd0kyITEby3DK6N9yIiU+X9OWJa/6vFYM/z6Kv8Z8LoFYnoEO/fsJYaCAIu8cye vqB3hDMWI28oU7KqTSJZsaWOB29P/zav6lpVCIaPE6tx/PrQgyjGSd9j5FearTNf cfJmVnYwy+oPYDmkRNA7YfzXLs+w1Ykzno0LzH++kgWXsjgNoC/UUyv8gqC7qBNs v97FYy6P5n2YfWHts0hkpsvmKswlRVoN3je5FlRcptLeuaVfpYg3CYac0rjucQol VcjDIZCvl2DEzvrRGO4hPoYDYpJKOS238q9HChPkrc8H7K2Q/4zAYbRz9I4tHovw nvazxvDINpNORs/5P/q07UZ7ZyfytSqhlwMfdPUcznJJkS8xn0c27tZtLdJzUAJS 7QyVX07mNMbjbo7aytu1kTrFoHpB6GrYYnmhzF64et1UuklL4wgBActacF3orhn+ Flfe2XWmObFrkhfJs1iqczAj+zukEHYoQ4JoTiPysvyTDr5Fkf/5xat/u1zyg98u 2Tp7ySaa2YehDmFM6KbKf9KP0XKfIVvtETExpFNJaVvoeOpxR0o= =ZOOe -----END PGP SIGNATURE----- --MFlxhIsZe/3eGhB7--