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 1sFTND-002cOO-Fu for pgsql-hackers@arkaria.postgresql.org; Fri, 07 Jun 2024 06:46:52 +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 1sFTNB-0096lS-8H for pgsql-hackers@arkaria.postgresql.org; Fri, 07 Jun 2024 06:46:50 +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 1sFTNA-0096lK-US for pgsql-hackers@lists.postgresql.org; Fri, 07 Jun 2024 06:46:49 +0000 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sFTN9-000Pt3-Rp for pgsql-hackers@lists.postgresql.org; Fri, 07 Jun 2024 06:46:49 +0000 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-52bc121fb1eso82237e87.1 for ; Thu, 06 Jun 2024 23:46:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717742807; x=1718347607; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=ITi26y1apcehn8WHG0bCPM1oiO3yv5Ay/sAoXPRJl7Q=; b=XqH5l1S7hsANUOUPGG5Hfxo+br6BPUOIw2ab1ZB6ypV122lOCQpNihjygE7yoURTSO HdrdIm7/dFsWzrxtmvOPWqTIFP7Syh4zoMsUhV+kB7uesEufivCXbIdpyTmhv/9Qp6Fg wF69NdRlF+4y0az9SbJeMloUCF/CpiqIPT0EXKeDDwTzh/S0htjOVe9hohnHtO7crFWu 8b4qlhzdymgdUyJVTzOtxCJHsYF/fuUC5JVs3PslXuSxMikn3Tmcyy738K6Bzst2G5OV Qh8J6PYmnh7REkTtiBERAppVPJnm36TR3ahXspTZzC8qbngQeGW/kvGlqwbuArf9rLhw 5krw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717742807; x=1718347607; h=content-transfer-encoding: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=ITi26y1apcehn8WHG0bCPM1oiO3yv5Ay/sAoXPRJl7Q=; b=QQVK31G2YKs+ZAnHkwkUNmzztNfhvQdYKJORUeQa0Qfd0nlpfo2MEmfbD9QyDonxeT +X3drAa7Jum7bMaEJNbxOS5gPiaJGreqQnncW3U1jp/sHqE6baNI6iSwyWxL+vgBlInS EjmrrLil+KekEuK/XEwYtxJErYimYj+nvvy/+uEd+6f1RwHSgkTT4a6t4deFjHLVgUWN ZivMUUJeVS3cQo+nXZkxY152dBdYX8kkel78bIfSFKMl/PpH6UpVRCme+u2wvEyTW8D4 7TjJjCOWDIEbiezv73Nux3eukrDZKLA6Uf0BJ6hwNilOI7vdxWKVPbbr7Iuegli8VLJi O/9Q== X-Gm-Message-State: AOJu0YwCGecFOey/RnMMVroecq9xgbPCm9ZREmVIWQCXC761JR6J6F8j hMOn0/kTpO7d1DIFT1nfBaqXJoI4LtLqzV270bKG3LGlbFqhpYsZwVXCoYR6KLA5+ccjsMdcS3J qGfJtib0iGR6IZIdFRHdKZonTRBnu++DY X-Google-Smtp-Source: AGHT+IFmsvU06jJqz11rX+my6E+cQ1v2F/yJOdk5WjpbGTfZR05kmK2SgT9d2BX3QOt5Dg1XOPup0runQu+nqP5/ZYo= X-Received: by 2002:ac2:464b:0:b0:52b:98ab:6100 with SMTP id 2adb3069b0e04-52bb9f79b3fmr1003133e87.15.1717742806586; Thu, 06 Jun 2024 23:46:46 -0700 (PDT) MIME-Version: 1.0 References: <70e1cca9-ff89-4e76-a611-d38bcc0e14ad@yandex.ru> In-Reply-To: <70e1cca9-ff89-4e76-a611-d38bcc0e14ad@yandex.ru> From: Dilip Kumar Date: Fri, 7 Jun 2024 12:16:30 +0530 Message-ID: Subject: Re: Vacuum statistics To: Alena Rybakina Cc: PostgreSQL Developers , Andrey Lepikhov , Andrei Zubkov Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, May 30, 2024 at 11:57=E2=80=AFPM Alena Rybakina wrote: > > On 30.05.2024 10:33, Alena Rybakina wrote: > > > > I suggest gathering information about vacuum resource consumption for > > processing indexes and tables and storing it in the table and index > > relationships (for example, PgStat_StatTabEntry structure like it has > > realized for usual statistics). It will allow us to determine how well > > the vacuum is configured and evaluate the effect of overhead on the > > system at the strategic level, the vacuum has gathered this > > information already, but this valuable information doesn't store it. > > > My colleagues and I have prepared a patch that can help to solve this > problem. > > We are open to feedback. I was reading through the patch here are some initial comments. -- +typedef struct LVExtStatCounters +{ + TimestampTz time; + PGRUsage ru; + WalUsage walusage; + BufferUsage bufusage; + int64 VacuumPageMiss; + int64 VacuumPageHit; + int64 VacuumPageDirty; + double VacuumDelayTime; + PgStat_Counter blocks_fetched; + PgStat_Counter blocks_hit; +} LVExtStatCounters; I noticed that you are storing both pgBufferUsage and VacuumPage(Hit/Miss/Dirty) stats. Aren't these essentially the same? It seems they both exist in the system because some code, like heap_vacuum_rel(), uses pgBufferUsage, while do_analyze_rel() still relies on the old counters. And there is already a patch to remove those old counters. -- +static Datum +pg_stats_vacuum(FunctionCallInfo fcinfo, ExtVacReportType type, int ncolum= ns) +{ I don't think you need this last parameter (ncolumns) we can anyway fetch that from tupledesc, so adding an additional parameter just for checking doesn't look good to me. -- + /* Tricky turn here: enforce pgstat to think that our database us dbid */ + + MyDatabaseId =3D dbid; typo /think that our database us dbid/think that our database has dbid Also, remove the blank line between the comment and the next code block that is related to that comment. -- VacuumPageDirty =3D 0; + VacuumDelayTime =3D 0.; There is an extra "." after 0 --=20 Regards, Dilip Kumar EnterpriseDB: http://www.enterprisedb.com