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 1smC9F-003x40-AL for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Sep 2024 13:03:41 +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 1smC9D-00A0iA-P7 for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Sep 2024 13:03:40 +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 1smC9D-00A0hG-5h for pgsql-hackers@lists.postgresql.org; Thu, 05 Sep 2024 13:03:39 +0000 Received: from fhigh7-smtp.messagingengine.com ([103.168.172.158]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1smC9A-000HKX-T3 for pgsql-hackers@lists.postgresql.org; Thu, 05 Sep 2024 13:03:38 +0000 Received: from phl-compute-04.internal (phl-compute-04.phl.internal [10.202.2.44]) by mailfhigh.phl.internal (Postfix) with ESMTP id EEFC31140264; Thu, 5 Sep 2024 09:03:35 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Thu, 05 Sep 2024 09:03:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1725541415; x= 1725627815; bh=2VJEFRiAzbslH8sQg/4UqUFuxL9+XtzBmRTxFUmdc8w=; b=M fQ27NwZ1aQwIYOBpb5j5MASWuUJ7RcEyb67Vqbu8B0++ONnbKaeBpYhy4fabOeQx LWMjFE06/dHd0dVFBNCLUAQwCTaviFgKnnpV3rESUGKwHeSjip/orLZzpUjXjOIY eyW7j3P1+ER9PbfGjxXDcaQB7lCES8w3DvOrDhkmqfuvIixMI5eBEzWm1EGdWpxv euRTGJ7FKlZ9XAWw7/EnSzbcgTvHARzJBHfOI06h6+YolM8/MzorxpSvf2UyK5Qw cC1JVUQ2eb/OjvafV9whjrRX+ix3zgAKiFSD59INGsMozOLG+5sotK2eyJwp0z4T 0tKkZK1+f0ZEeLPsOzWyg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudehledgheelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvve fukfggtggugfgjsehtkeertddttdejnecuhfhrohhmpeetlhhvrghrohcujfgvrhhrvghr rgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgqeenucggtffrrghtth gvrhhnpedvkedtffduffdtffffheffhfejjefhgfeiueeukeejkeffgfdufffhudffffeu veenucffohhmrghinhepvghnthgvrhhprhhishgvuggsrdgtohhmnecuvehluhhsthgvrh fuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhhvghrrhgvsegrlhhv hhdrnhhoqdhiphdrohhrghdpnhgspghrtghpthhtohepfedpmhhouggvpehsmhhtphhouh htpdhrtghpthhtohepsggvrhhtrhgrnhguughrohhuvhhothdrphhgsehgmhgrihhlrdgt ohhmpdhrtghpthhtohephhhorhhikhihohhtrgdrnhhtthesghhmrghilhdrtghomhdprh gtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehlihhsthhsrdhpohhsthhgrhgvshhq lhdrohhrgh X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 5 Sep 2024 09:03:35 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1725541412; bh=SW4XeFCill71F1bWmnI312ebc9AQnT4wrp0SJ1y28JI=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=hn6eykbZYzsLDX0I9nPbBVUPi3/qpplrABRFDqSMZfA5I1HvxzmtldM8mD5PeK/sH LhzprQWtHfApBVJZd9mLcjT/o+3ve1HfAsXrN/taYocZSR8dmCPobE8Qb1IA/WBVwZ +Ep7oyo3X8N6KkI/2Xj1D7MGfrXBjRb9xtFivYrC8I+If1V3xtmcJfZIEXTuIrFq8O 1edZiOaw2AqiXKnom3ZdM0gB41eDLITP/qpcaSAjxRw3nrs0JGe8qFodAOeEwTzqxu M1CbZDkmFzRTYhzga/DhWE5CwKQkHXh/fRHvhwcQzpup2h/DcIrm+y6+WA6k06vhhn rFTTavVC8nzbQ== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id BF17FD35; Thu, 5 Sep 2024 09:03:32 -0400 (-04) Date: Thu, 5 Sep 2024 15:03:32 +0200 From: Alvaro Herrera To: Bertrand Drouvot Cc: Kyotaro Horiguchi , pgsql-hackers@lists.postgresql.org Subject: Re: per backend I/O statistics Message-ID: <202409051303.qumelxccgzzn@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2024-Sep-03, Bertrand Drouvot wrote: > Cons is probably allocating shared memory space that might not be used ( > sizeof(PgStat_IO) is 16392 so that could be a concern for a high number of > unused connection). OTOH, if a high number of connections is not used that might > be worth to reduce the max_connections setting. I was surprised by the size you mention so I went to look for the definition of that struct: typedef struct PgStat_IO { TimestampTz stat_reset_timestamp; PgStat_BktypeIO stats[BACKEND_NUM_TYPES]; } PgStat_IO; (It would be good to have more than zero comments here BTW) So what's happening is that struct PgStat_IO stores the data for every single process type, be it regular backends, backend-like auxiliary processes, and all other potential postmaster children. So it seems to me that storing one of these struct for "my backend stats" is wrong: I think you should be using PgStat_BktypeIO instead (or maybe another struct which has a reset timestamp plus BktypeIO, if you care about the reset time). That struct is only 1024 bytes long, so it seems much more reasonable to have one of those per backend. Another way to think about this might be to say that the B_BACKEND element of the PgStat_Snapshot.io array should really be spread out to MaxBackends separate elements. This would make it more difficult to obtain a total value accumulating ops done by all backends (since it's require to sum the values of each backend), but it allows you to obtain backend-specific values, including those of remote backends rather than only your own, as Kyotaro suggests. -- Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/