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 1r6MB1-000cI2-2O for pgsql-hackers@arkaria.postgresql.org; Fri, 24 Nov 2023 02:44:19 +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 1r6MAw-006qxM-SS for pgsql-hackers@arkaria.postgresql.org; Fri, 24 Nov 2023 02:44:14 +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 1r6MAw-006qxE-HZ for pgsql-hackers@lists.postgresql.org; Fri, 24 Nov 2023 02:44:14 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r6MAm-008CjS-Pd for pgsql-hackers@lists.postgresql.org; Fri, 24 Nov 2023 02:44:13 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 332B05C0179; Thu, 23 Nov 2023 21:44:03 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Thu, 23 Nov 2023 21:44:03 -0500 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:sender :subject:subject:to:to; s=fm1; t=1700793843; x=1700880243; bh=6i fVY0mclvFDf36sDrDbYFE+v5cy1qUE+iL9hhpwtNY=; b=0KIEvdkVTnEK5GxJw1 IwhBeBEWXy0QLeoOMdIYF+uqlNM++SiDn7oDBvMWfBEpfAl9XIxs6Y0o+KHdJ/kL 11sOTLhmF65FT/We+5PT8TbeXwhwIe/aBguRw1fA1dmL7rTf4gr/AY67spmmZX1p 44cFv+aO0E+JTtyR8KSk1qwWCE4f4Uyg7bQ0wKt7AbnAuC8Dz+ihEqjecxc+4do2 N+++rDd16l/2n6EgVNqBOjlZRyAWeLNiBjsW6sDLpAgL50eBsqaM0J1qZ3ivHO3X hkyHElORJyJ101VTD3iLm8cL0nwCIykZD+C0RLgGrG+JtyxRIpYetgw8RxQE2vd7 EtBA== 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:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1700793843; x=1700880243; bh=6ifVY0mclvFDf 36sDrDbYFE+v5cy1qUE+iL9hhpwtNY=; b=EF3xx8vlX9LvSvJQcIGdJrD9LNkU2 nXCJSb3nQg61mZKmtetx2QyYt4osxIC0Ui4TfvwuJrREaPyWTfw5AhHd3xFiWHkZ h1uYiEYzHS/Y7cmDIt3ucR7BOEeQF8kf6/R0kUNuvXjXj5hVp1n0U9Tvmuys9TND SNhG6U4oXmlbl1Mqf0fV+hFNbf6icUDt1EQUnRLYrw40hjNE9nP+HhdJHfYZteii DfzuBMcL925M5zgryegFWPD5Gsqe2iAIXI4brwLAfCnZxUCzG5QhoUL1Fv9AM1ZV ak2c193SO8KsJ01XbkL3/2PvLjsCoapy2OONirqxqfo/KlM0z5Lm+OzUA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudehgedgheduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne gfrhhlucfvnfffucdljedtmdenucfjughrpeffhffvvefukfhfgggtuggjsehgtderredt tddvnecuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesph grqhhuihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepteelieefudffhffhtdetleeg geegfffhkeeuveetiefgudduvedutefggeeivdejnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiih ii X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 23 Nov 2023 21:44:01 -0500 (EST) Date: Fri, 24 Nov 2023 11:43:58 +0900 From: Michael Paquier To: jian he Cc: Jim Jones , Garrett Thornburg , pgsql-hackers@lists.postgresql.org Subject: Re: PATCH: Add REINDEX tag to event triggers Message-ID: References: <37cd6187-d6ac-3cfc-a380-8ad1cc6270a0@uni-muenster.de> <9c5942ec-5c11-03b0-6611-8336044a5219@uni-muenster.de> <28176fb8-5169-ecf7-9b3c-82748dde76f0@uni-muenster.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="MF1RFsGvdfz13C+n" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --MF1RFsGvdfz13C+n Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Nov 24, 2023 at 08:00:00AM +0800, jian he wrote: > not sure this is the right approach. But now the reindex event > collection is after we call index_open. > same static function (reindex_event_trigger_collect) in > src/backend/commands/indexcmds.c and src/backend/catalog/index.c for > now. Knowing that there are two calls of reindex_relation() and four callers of reindex_index(), passing the stmt looks acceptable to me to be able to get more context from the reindex statement where a given index has been rebuilt. Anyway, as a whole, I am still confused by the shape of the patch.. This relies on pg_event_trigger_ddl_commands(), that reports a list of DDL commands, but the use case you are proposing is to report a list of the *indexes* rebuilt. So, in its current shape, we'd report the equivalent of N DDL commands matching the N indexes rebuilt in a single command. Shouldn't we use a new event type and a dedicated SQL function to report the list of indexes newly rebuilt to get a full list of the work that has happened? > given that ProcessUtilitySlow supports the event triggers facility. > so probably no need for another REINDEXOPT_ option? Right, perhaps we don't need that if we just supply the stmt. If there is no requirement for it, let's avoid that, then. - ReindexMultipleTables(stmt->name, stmt->kind, ¶ms); + ReindexMultipleTables(stmt, stmt->name, stmt->kind, ¶ms); If we begin including the stmt, there is no need for these extra arguments in the extra routines of indexcmds.c. As far as I can see, this patch is doing too much as presented. Could you split the patch into more pieces, please? Based on v4 you have sent, there are refactoring and basic piece parts like: - Patch to make event triggers ddl_command_start and ddl_command_stop react on ReindexStmt, so as a command is reported in pg_event_trigger_ddl_commands(). - Patch for GetCommandLogLevel() to switch ReindexStmt from LOGSTMT_ALL to LOGSTMT_DDL. True that this could be switched. - Patch to refactor the routines of indexcmds.c and index.c to use the ReindexStmt as argument, as a preparation of the next patch... - Patch to add a new event type with a new SQL function to return a list of the indexes rebuilt, with the ReindexStmt involved when the index OID was trapped by the collection. 1) and 2) are a minimal feature in themselves, which may be enough to satisfy your original case, and where you'd know when a REINDEX has been run in event triggers. 3) and 4) are what you are trying to achieve, to get the list of the indexes rebuilt knowing the context of a given command. -- Michael --MF1RFsGvdfz13C+n Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmVgDe4ACgkQnvQgOdby QH0GtA//XxkVrZOC058j5DsdNnjyK41b96jprbmFJYIS7pYSRju3HzgO1KsqMobh ieE6EyPk1B1SJZf7WqopOgfR2tubqXJwF+vGUjio93FRD3Qlefr+rCbFA+MxRnvE Pc3XyyhHw/RBcyjE5wTO3n1NzvmWgB3I1SsvJDhLW15JlBa6x5CnHll6ZjeExeuE k5gPCy2jSOj7GR/gb2x4FRotOw0qr1KSPY7lUDAwNZ34xttnLbdmftQjWVnFq3bH qIwSnFtBoTF8tXCRGpbpK7T+z6dxyu07EpaxNkmwwpg6eBpCrMUGyUKwl3blpHfe OJh8VuiKlggoJaX/LXjSoSXF9rO5VtA5FpCMghrrdfOgD/facIj/+K1hjS/28xwB RnPR3BzjLj5ZyEmHxlDk/uB+lzORrThs5OvxypR1i5btfCuA4qxGNqSkE3k2/LtP sEEo0iyVIeC8Lf5GFkjE1JTtWp0BOyGwY1ngi42yv8UWOK8xV/I4JlJlgSG/1k0g 3KMYvUShiHfHhjib/+V/RwCP1HHbj5Uxo3bzMUypcP/Vl4RncaLwM/n25HLVanFq RiCfZThrfqiBWYfSql+zqi3lOnOb57jaFejcW/kYI79Vp3Nsr+tGNZ8j6FHdhqNL E+2y2A6X7CraGEtepHK6DaZj6z+P226TMuz1xhjJzdizoCXNvjg= =UhUI -----END PGP SIGNATURE----- --MF1RFsGvdfz13C+n--