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 1sp6c3-00GbUl-LQ for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Sep 2024 13:45:28 +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 1sp6c3-0034w6-AF for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Sep 2024 13:45:27 +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 1sp6c2-0034vG-WF for pgsql-hackers@lists.postgresql.org; Fri, 13 Sep 2024 13:45:27 +0000 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sp6bz-000zoN-Jw for pgsql-hackers@lists.postgresql.org; Fri, 13 Sep 2024 13:45:26 +0000 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-2059204f448so20464845ad.0 for ; Fri, 13 Sep 2024 06:45:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726235122; x=1726839922; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=TysmaDGSWsmjfRmaoSuOdeg9IeOWl4cOaO5iHDEDyKs=; b=JdLW6tUns7+jj1qcrHepuLBCMzTdixGddkqt3raVdlQ2Umhipatb6iqNPEbZOcpukE 2SsC6UFmB+wmp7RBn5sVrWGMmfx6ioNYYYBRISCUEMhwWVb+BiH60M2IaE1pGa0lRugA 63nisE/M9peyIOlJcdhXPzAeOB9UlzN659hJhPPcmJ6C2knOolSDV0DFIEyS2hi6NNtA lDd9F1oNYhL6JA+OHwBb7DGvkwrBV5gug2OsPnt8/QPgXCv3utZgfqFm2u+OXD50vHil fnHdio9MORfuezdPiYF4IcWra00VW+uJJw6+ddPuDdJsq7Zk5gmz4hwa/vuHV5eGZw4t eFnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726235122; x=1726839922; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=TysmaDGSWsmjfRmaoSuOdeg9IeOWl4cOaO5iHDEDyKs=; b=OZnv9w3BCbPH+au1vUKH9AkUKYvRyPbWeDa6gmcP4GgZmmTzNDqAs+qTu9j7gONbuS ELy+Xkil19K/PYx/wI6OnYonUws4LzaFjuAakSblguXEAbQcyzNMDZCiGfXgAtnO8SRn 6pvdaBKB5XpPlcqkIsD367t7XdDgC1g8+DUr3BV4WkAUPQ2QmiBxXh63frFaxDyIOcOr smvwYP+/QEJbPLf701Ry8lMVUuIc3DN13nS42XiiQNJJ3znNWZGVdaCfyrYS9P4T+6S7 Yq5WVSFzUSUmV00Wk9sygXTfb6UBDsswiL7VbXCdxQZnjPAK4XzgL7HEB655cDLxJaVT W7mQ== X-Forwarded-Encrypted: i=1; AJvYcCXLW5rnItAOVe4dRkoNtqZnZIbhGwpRusxCJvRQ4A0ND4ezBMo7+7t0CP3AKggpuEcVOBJl/KfQkDc9RwJo@lists.postgresql.org X-Gm-Message-State: AOJu0YwPWBxBIkf1b75XQtrX6vWkXzayIs9b+47nqyN/yIK9k4H5Q7rD Ql2LYu6t2KyQOSZngylmD7WzT9yhjwX0lP6oF1J+ta3MAUI6V9y669GxbVvnmq/1b7tOEfiKgdg ObhXb87mOyfq9bhULQSML8RGJl/Q= X-Google-Smtp-Source: AGHT+IEM8MtYKj8/QbrYrukOnaXn9WlKxwD72SIWUw8SJMW+OLlLxEwsHo/f3sungZOh2J8vNEyV8hoG1QBML9OBnYA= X-Received: by 2002:a17:90a:6888:b0:2c4:e333:35e5 with SMTP id 98e67ed59e1d1-2dba00826f1mr7396256a91.36.1726235121393; Fri, 13 Sep 2024 06:45:21 -0700 (PDT) MIME-Version: 1.0 References: <202409051303.qumelxccgzzn@alvherre.pgsql> In-Reply-To: From: Nazir Bilal Yavuz Date: Fri, 13 Sep 2024 16:45:08 +0300 Message-ID: Subject: Re: per backend I/O statistics To: Bertrand Drouvot Cc: Alvaro Herrera , Kyotaro Horiguchi , pgsql-hackers@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, Thanks for working on this! Your patch applies and builds cleanly. On Fri, 6 Sept 2024 at 18:03, Bertrand Drouvot wrote: > > - As stated up-thread, the pg_stat_get_backend_io() behaves as if > stats_fetch_consistency is set to none (each execution re-fetches counters > from shared memory). Indeed, the snapshot is not build in each backend to copy > all the others backends stats, as 1/ there is no use case (there is no need to > get others backends I/O statistics while taking care of the stats_fetch_consistency) > and 2/ that could be memory expensive depending of the number of max connections. I believe this is the correct approach. I manually tested your patches, and they work as expected. Here is some feedback: - The stats_reset column is NULL in both pg_my_stat_io and pg_stat_get_backend_io() until the first call to reset io statistics. While I'm not sure if it's necessary, it might be useful to display the more recent of the two times in the stats_reset column: the statistics reset time or the backend creation time. - The pgstat_reset_io_counter_internal() is called in the pgstat_shutdown_hook(). This causes the stats_reset column showing the termination time of the old backend when its proc num is reassigned to a new backend. -- Regards, Nazir Bilal Yavuz Microsoft