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 1uF7tc-000GOa-VN for pgsql-hackers@arkaria.postgresql.org; Wed, 14 May 2025 08:55:25 +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 1uF7tb-0096ae-OB for pgsql-hackers@arkaria.postgresql.org; Wed, 14 May 2025 08:55:23 +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 1uF7tb-0096aW-D8 for pgsql-hackers@lists.postgresql.org; Wed, 14 May 2025 08:55:23 +0000 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uF7tY-001pWa-2D for pgsql-hackers@postgresql.org; Wed, 14 May 2025 08:55:23 +0000 Received: by mail-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-30a8cbddca4so7545398a91.3 for ; Wed, 14 May 2025 01:55:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747212918; x=1747817718; darn=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=LdyL0MlqFFsGR24AE82RuoxJit3HfxuLUdTzbzK8Lus=; b=aMp3TcD8mK++OT036R/l4rA6azN7XNh3wH9wcT0IFfc6pSV0iTWsPskj4TnE4RBLEU BHt/ZsZd3hhF1qxrt6MUBYrBHPmp4TC3SysxXTS1WJeVCUGZhZpYl3xm7HOZEWrDayUI Uab7xS0sUV4/ZmuLGjJQD2pPrd+jZbIktYycYuj/1ql8KRLirHRouOw3ioVlHQgqhSjo k3WlsRUCBASMJTu2IZT+b/1sFzQBKjC/3N74DjCzNpjoqhRKE0yfm686H2ymZi2dIZfJ XzPBzHnPdHdNqRLyg8srx/5/5XI+RAafr7s2nDdU5b0OsMY8JOCGTrQmJ98CGlNMzvYc JpOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747212918; x=1747817718; 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=LdyL0MlqFFsGR24AE82RuoxJit3HfxuLUdTzbzK8Lus=; b=AzYDm7d7GMENW6dAkWCeH1rf/FH1XxMokKR6bFSSdhd5rFwgx3p3SR5LNdXtQBPWwG XMafBjUHu2kUi65BPYXTkJYJ6aCBfGy7oEPQTDwAh2cZxa6omP0lnx3Qfpg+RPycxT9O MGq4ezgqbsF1+x8Xjg9l0wsqLSWokHFU3DHUik0hsnuE0XOCzICGkxabT9JNAh8BZ/bd Omjxg7fiQzKFABgXZiNw3bKNJaKxDCw2lWihzQLogjeJ4jofK4ykQ05ONKghRu7MSgwH Yu6jUJzYm0Cw3dDefIm+qdqVAT4kSYX9skMu28ZCbLnvvvzgwNtrSnNhPVcJZEsqfftE IPwA== X-Forwarded-Encrypted: i=1; AJvYcCWxiXBzC6sK5RP2NDjusZD73p3wXBr3WP13rcmTiEQYew+8EIlWsmsbS9OsRs1Na2acllZk7hoOqC2LvYr2@postgresql.org X-Gm-Message-State: AOJu0YxBYOjNFMbxJs7NRD4iNqmKFxTOq221GER5i9DZnYnhconzSpTi lINPGJz5nbrpHxRtCf6AITVE5Sn03isF7WgZ8re3lzig9+WHOLA160qOZEgZubsqgWOYQg2tfAS jK8AMCDI1030zGNlhLiCifEweaYA= X-Gm-Gg: ASbGncueEyrf1KqBQh/HYIUUi1lKdhSVkiigUZGGCJ0fu0vWHjL0+3tn7eAss/foH+J Czxiuh+a2MSru/IYNUb8xn/WnJTyTxuAKsEowPppAnWMejk8IiLns19WWqbTfCUEs7y5F0Gp02q 7mEuCr9equEyO/B0q+uxukP/GCb4lN66GAPrw= X-Google-Smtp-Source: AGHT+IG8jCX44pyLYsn/lkNX3XkNlSKSuY4g+4o+1DYJefhUexwib1mYxwiyaLf86r8nPWpjcxNndkMaoPApwb4vXqo= X-Received: by 2002:a17:90b:54c7:b0:30e:3338:8c0e with SMTP id 98e67ed59e1d1-30e33388c1emr2933474a91.27.1747212917904; Wed, 14 May 2025 01:55:17 -0700 (PDT) MIME-Version: 1.0 References: <86f76aa5-1ab5-4e2e-9b15-405051852a2a@postgrespro.ru> <1e81a0a1-a63b-48fb-905a-d6495f89ab73@postgrespro.ru> <0b4eefc7-4c38-4caa-b2ca-a4c75dd7dd12@postgrespro.ru> <333c2306-c401-4959-9f0c-a44c670a11a9@postgrespro.ru> <513f0188-b093-4cc8-98cf-4c324570d525@postgrespro.ru> <47a7b784-5218-43f2-96e3-65f9a729c5a5@tantorlabs.com> <5583261b-eede-4341-b3b1-91650fefc1cf@postgrespro.ru> <2a04ad18-5572-4633-848b-eb57209e7ac0@postgrespro.ru> <2f48399f-2959-4483-938f-64edb863ca76@postgrespro.ru> In-Reply-To: <2f48399f-2959-4483-938f-64edb863ca76@postgrespro.ru> From: Amit Kapila Date: Wed, 14 May 2025 14:25:05 +0530 X-Gm-Features: AX0GCFucWHGlJs9Wo4Vet0I7Dn7oYwFdaUPOkIoA4Haxm3xdIkrfevnOQOr8xIs Message-ID: Subject: Re: Vacuum statistics To: Alena Rybakina Cc: Alexander Korotkov , pgsql-hackers , Jim Nasby , Bertrand Drouvot , Ilia Evdokimov , Kirill Reshke , Andrei Zubkov , Masahiko Sawada , Melanie Plageman , jian he , a.lepikhov@postgrespro.ru, Sami Imseih , vignesh C 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 Tue, May 13, 2025 at 3:19=E2=80=AFPM Alena Rybakina wrote: > > On 12.05.2025 08:30, Amit Kapila wrote: > > On Fri, May 9, 2025 at 5:34=E2=80=AFPM Alena Rybakina wrote: > >> I did a rebase and finished the part with storing statistics separatel= y from the relation statistics - now it is possible to disable the collecti= on of statistics for relationsh using gucs and > >> this allows us to solve the problem with the memory consumed. > >> > > I think this patch is trying to collect data similar to what we do for > > pg_stat_statements for SQL statements. So, can't we follow a similar > > idea such that these additional statistics will be collected once some > > external module like pg_stat_statements is enabled? That module should > > be responsible for accumulating and resetting the data, so we won't > > have this memory consumption issue. > The idea is good, it will require one hook for the pgstat_report_vacuum > function, the extvac_stats_start and extvac_stats_end functions can be > run if the extension is loaded, so as not to add more hooks. > But I see a problem here with tracking deleted objects for which > statistics are no longer needed. There are two solutions to this and I > don't like both of them, to be honest. > The first way is to add a background process that will go through the > table with saved statistics and check whether the relation or the > database are relevant now or not and if not, then > delete the vacuum statistics information for it. This may be > resource-intensive. The second way is to add hooks for deleting the > database and relationships (functions dropdb, index_drop, > heap_drop_with_catalog). > How does pg_stat_io manages this? I mean how it removes objects that are dropped? Does some background task removes it? > > BTW, how will these new statistics be used to autotune a vacuum? > yes, but they are collected on demand - by guc. > > And > > do we need all the statistics proposed by this patch? > > > Regarding this issue, it was discussed here and so far we have come to > the conclusion that statistics are needed for a deep understanding of > the work of vacuum statistics [0] [1] [2]. > I haven't gone through the emails, but my opinion is to break the number of stats into some important subset of stats first and then keep enhancing it. Right now, the patch struggles with two concerns: one is what the design should be to capture the required stats, and the second is convincing ourselves whether we need all the stats it is trying to expose. Breaking into a smaller subset of stats could alleviate the second concern. --=20 With Regards, Amit Kapila.