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 1tZiR0-00CGRD-2Y for pgsql-hackers@arkaria.postgresql.org; Mon, 20 Jan 2025 03:26:42 +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 1tZiPy-00BdFH-QK for pgsql-hackers@arkaria.postgresql.org; Mon, 20 Jan 2025 03:25:39 +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 1tZiPx-00BdF9-Ja for pgsql-hackers@lists.postgresql.org; Mon, 20 Jan 2025 03:25:38 +0000 Received: from fout-b4-smtp.messagingengine.com ([202.12.124.147]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tZiPt-000T5F-2J for pgsql-hackers@postgresql.org; Mon, 20 Jan 2025 03:25:37 +0000 Received: from phl-compute-10.internal (phl-compute-10.phl.internal [10.202.2.50]) by mailfout.stl.internal (Postfix) with ESMTP id 40B2F1140127; Sun, 19 Jan 2025 22:25:31 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-10.internal (MEProxy); Sun, 19 Jan 2025 22:25:31 -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:subject :subject:to:to; s=fm2; t=1737343531; x=1737429931; bh=TiHLe7kS97 waohD8VkNaKRwQPCobayD984XZ9zAz4SY=; b=i8L7J2xGje2VE7vSmqnvANj7es 4LUnhrr086IzOSi/ZosXxsodfLX4TuIgY6yk9ersTwNXS+nfkS9fBovDq8Svx5eB UTNkATjKS7jlAVm0jugGL2gZztTlXP8pLcXiwxZYdiu+A9YVFwOG5qNW1/q/l/Px tUmnUuauanhUZ33CVDk9tOm0dfFxh7hKMieQ47lomJm0/Tz2zjuGImdICIvvgdHo 0bA2WcpEx4P3m+Wqjd5gafjO3KgIZmOi+vUY+kqlZoW7GJu0h9lGThgEkK2yqsLp 7rVvCZTXDwlPL0C+xuafXhm3rE3QHMeh74xUxLd8dQDxz24aos7O36jt5Sag== 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= 1737343531; x=1737429931; bh=TiHLe7kS97waohD8VkNaKRwQPCobayD984X Z9zAz4SY=; b=WNrgSDoDiT9UsKWGaXNtkkBRBPEH0gN7BsdKLfcFWgPpCKr/1Ny ZpcDF0f6u05MhFclD+MbjzlOyzji+pxMBThuWVsmL4L4/Wroz6Pmv7g80aanhfHd Igz/mFSdCMIIEP3Yp8zkhCDv9LVn8KUKCWHlB7aRFNwO2P4XGMw/bDsMQ/kpG+5L EdcabvwqOyuMNoB8G2sV1NG5NvmoISziyn/2FSumIl/fzy8C96kWzIJE4j20b+Yw G9eZVCNkGqSNZp/BaY+mBAdFLKT95lsxO2u6Lj9I6vuz3UQ+cI4m4PRgpTxiAHRr BXSST1tlRpq4VpKEwCe5+ZU0L0EBY4TnaBg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrudeikedgheeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnegfrhhlucfvnfffucdljedtmdenucfjughrpeffhffvvefukfhf gggtuggjsehgtderredttddvnecuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruc eomhhitghhrggvlhesphgrqhhuihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepteel ieefudffhffhtdetleeggeegfffhkeeuveetiefgudduvedutefggeeivdejnecuvehluh hsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhes phgrqhhuihgvrhdrgiihiidpnhgspghrtghpthhtohepfedpmhhouggvpehsmhhtphhouh htpdhrtghpthhtohepshgrmhhimhhsvghihhesghhmrghilhdrtghomhdprhgtphhtthho pegsvghrthhrrghnuggurhhouhhvohhtrdhpghesghhmrghilhdrtghomhdprhgtphhtth hopehpghhsqhhlqdhhrggtkhgvrhhssehpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 19 Jan 2025 22:25:28 -0500 (EST) Date: Mon, 20 Jan 2025 12:25:17 +0900 From: Michael Paquier To: Sami Imseih Cc: Bertrand Drouvot , pgsql-hackers Subject: Re: POC: track vacuum/analyze cumulative time per relation Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="/zk1wQqtB809JthL" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --/zk1wQqtB809JthL Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Jan 17, 2025 at 09:42:13AM -0600, Sami Imseih wrote: > Indeed. Corrected in v5 I can get behind the idea of the patch. + PgStat_Counter total_vacuum_time; + PgStat_Counter total_autovacuum_time; + PgStat_Counter total_analyze_time; + PgStat_Counter total_autoanalyze_time; } PgStat_StatTabEntry; These are time values in milliseconds. It would be good to document that as a comment with these fields, like PgStat_CheckpointerStats and others. Perhaps they should be grouped with their related counters within PgStat_StatTabEntry? Or not. The patch makes sense here in terms of passing down to pgstat_report_vacuum() the elapsed time and the end time to avoid an extra GetCurrentTimestamp() when calculating if the logging should happen. However in analyze.c.. +++ b/src/backend/commands/analyze.c [...] + TimestampTz endtime = 0; [...] - TimestampTz endtime = GetCurrentTimestamp(); - if (verbose || params->log_min_duration == 0 || TimestampDifferenceExceeds(starttime, endtime, This is incorrect, endtime is never set. I would give priority to the symmetry of the code here, using for the analyze reporting the same arguments as the vacuum bits, so as we don't call GetCurrentTimestamp in the proposed changes for pgstat_report_analyze(). + if (AmAutoVacuumWorkerProcess()) + tabentry->total_autovacuum_time += elapsedtime; + else + tabentry->total_vacuum_time += elapsedtime; [...] + if (AmAutoVacuumWorkerProcess()) + tabentry->total_autoanalyze_time += elapsedtime; + else + tabentry->total_analyze_time += elapsedtime; These could be grouped with their previous blocks. -- Michael --/zk1wQqtB809JthL Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmeNwh0ACgkQnvQgOdby QH07MQ//V9f232Lnk0dYQ4rtdcPRnPEQmNmKkV2UgbK5+d7PRyCGIzUXIaHq+/ZK PhZnTHql8FSpoWyg0dF2kmNX/I+SAVW9dF9HAfyfq4bv0vWOfdlwryOVF1n4ygEm AUuOUjYn+I7GyiLjKdd25EyaZoVPgnMVtk5OvfOyoz6U0pa+ua01Gr5BDXY3XeFl WnYebeu4sW47S8pJ2lUKXj5FFRClu0atLOy/7mJ+Lp4apvbEsCgxtgdyFTjAHZ6O SrxU3t1eHjPdd933m4FaDCsyWXsmMmnxJp9DILoTH3oW+dgrQoACp3KLYIn1Pidl l+Sx16JQJywuQ8PmrXusgVo/zLl/SZZRLgegBG5Vnn0JTuihkoseEPXyNHg/FCoK D89Tn2tM+gSLfFFM9SI7ALnifQimPQUZ1Mr0jjm4VOHY9HBM5uQ1opniAgJxB1kE ZN+xm7Zn3jr4J/rwTJwdVi8wQIvSjnPA+qKKDqSXJAFGU2Pd0ezrunlsevufBiDX lQpf6MeUhL9HICGC5hmVwvB78FG0G1Lc2ncpQg6i+C35NPicCNPnPiN/Bsd/m2KO ZPP4beslId0oEsmeT5gawiHK32FhjnwT5z0BBN1INKrylvgC37CQUSeo14L/u9a0 85sS8KLPbF7pv+h0nMbwODtF8NUMKLTahQ5+JMAZINu8nR6ZMOU= =AypN -----END PGP SIGNATURE----- --/zk1wQqtB809JthL--