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 1uCAiX-00BXm1-Sl for pgsql-hackers@arkaria.postgresql.org; Tue, 06 May 2025 05:19:46 +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 1uCAiW-006vjQ-Vk for pgsql-hackers@arkaria.postgresql.org; Tue, 06 May 2025 05:19:44 +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 1uCAfH-006rbC-LR for pgsql-hackers@lists.postgresql.org; Tue, 06 May 2025 05:16:23 +0000 Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uCAfE-000OR0-1B for pgsql-hackers@lists.postgresql.org; Tue, 06 May 2025 05:16:22 +0000 Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-54b166fa41bso6848143e87.0 for ; Mon, 05 May 2025 22:16:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1746508580; x=1747113380; 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=8JDd9YtwZvk+oqGm2sgDUzhFxmjYVh+yeXL2fwGtFno=; b=B6fUG8zr1FSjSdMWYTb3dv0c/89NsxIa0UW1A6Ev46bujfdIlrcQcwobCaZe0c3pwm qDxfIUOOJU+LdUf6NbqaA+TFWK01nkHCX1WpAIcDQGMiqQawV3cCso9rk4YxEfEsGspY f3MbRxi15g/NwEaGFTzwwVYZ3U24HC7rHX1ZFpKdfZVsDcrN/HLt7zDtKtcIaxrJcwd1 FXUstAk/9N2x0AFafLwdSNuXjW+uoNZDgZmHwsFTmvPx0czzPRIAYFOo2M/8QIUIoWyP JF1U6wAa/eiVW4Nr3EKhOAW8q3iICqdzGBvKiqdmQms7BYZ8vzq/6KQ64SyAjJiCNPpT cueA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746508580; x=1747113380; 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=8JDd9YtwZvk+oqGm2sgDUzhFxmjYVh+yeXL2fwGtFno=; b=PO9rsLzFXqkCCUy1pUqdq+QZhumLzOgy4G7qnzZitMuhngvbp4LSKo3elJ44ndrV/n i5O4gy1nF70Vqwd8fbG7Vytdgkb2puwpyKlyRtgRtWy0ny4+aUyR4YH7ejcDhL5jAzE6 mo3HFrLdHXjiaBpnCXO9jcl4yKt29ocy7pMXkVodL81sJKdQ+eDAxDEFRs8sEV2yN3Bq rSYQhxmqhY5e+n3+018z4tavkhigyu3JyVKSnGtzoKecXmCOdwYtOIJwSknkdRAjPzY+ aDCIDZFJCKqj04P7JNblzSWhghYgGUzFH97fz5py9jFkbQJn6Vddsa9g6RtFb5lf6Knz V5MA== X-Forwarded-Encrypted: i=1; AJvYcCVh6vb/ZeGGLc9GDJud/14NruGp/d0fQdw9RuoK+daBahXB15yBZqDaQdeVKyxkOHfLlzZHn0/TmcJ+G+fl@lists.postgresql.org X-Gm-Message-State: AOJu0Yz5YLlUaEFQEnmuAgpPTQ85UxCB4za5M2MZQtJP+Fv51XQTRCkf Ed3PgZaL6wnHryP3wgvdS2sVW/lOZrJ0/tPdNHUP3zqC2G98DhgRU6l++y40DB03/Jr3oQOgHOE fjIqXhxAaIg3GENAtbT+Ij4jTt7c= X-Gm-Gg: ASbGncvrl/n1H3MT38Ei9wGu387l2bjugpj/kh4x8O2SGDlnHX2eMdYfnQ8barefgig sA+hJm2FnCOCP9x0X2MZgDpywgEGV8dYDEXUC/wx52aXoO1YFiQZv2M/QX6ESfRHYy0ll//W5/G hsWqe6qroYzHdBl7rfPjWBcsU= X-Google-Smtp-Source: AGHT+IEnnT0tMwC+ECDtzp2lcx4Yd9PJhaD810mhQ7w22OlJEJ530GjrhK4PvFldwuebm87sDRyGOu3r4jBe/4DwLfI= X-Received: by 2002:a2e:9e86:0:b0:30b:f23e:77fb with SMTP id 38308e7fff4ca-32349059762mr25097691fa.21.1746508579792; Mon, 05 May 2025 22:16:19 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Masahiko Sawada Date: Mon, 5 May 2025 22:15:43 -0700 X-Gm-Features: ATxdqUHgWvgdpN4-ULGZX-8nzRYk8qud9IdqtBkkMQPStkZBfi-nZBn1sIWEDdg Message-ID: Subject: Re: POC: Parallel processing of indexes in autovacuum To: Sami Imseih Cc: Daniil Davydov <3danissimo@gmail.com>, Maxim Orlov , Postgres hackers 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 Mon, May 5, 2025 at 5:21=E2=80=AFPM Sami Imseih wr= ote: > > >> On Sat, May 3, 2025 at 1:10=E2=80=AFAM Daniil Davydov <3danissimo@gmail.= com> wrote: >> > >> > On Sat, May 3, 2025 at 5:28=E2=80=AFAM Masahiko Sawada wrote: >> > > >> > > > In current implementation, the leader process sends a signal to th= e >> > > > a/v launcher, and the launcher tries to launch all requested worke= rs. >> > > > But the number of workers never exceeds `autovacuum_max_workers`. >> > > > Thus, we will never have more a/v workers than in the standard cas= e >> > > > (without this feature). >> > > >> > > I have concerns about this design. When autovacuuming on a single >> > > table consumes all available autovacuum_max_workers slots with >> > > parallel vacuum workers, the system becomes incapable of processing >> > > other tables. This means that when determining the appropriate >> > > autovacuum_max_workers value, users must consider not only the numbe= r >> > > of tables to be processed concurrently but also the potential number >> > > of parallel workers that might be launched. I think it would more ma= ke >> > > sense to maintain the existing autovacuum_max_workers parameter whil= e >> > > introducing a new parameter that would either control the maximum >> > > number of parallel vacuum workers per autovacuum worker or set a >> > > system-wide cap on the total number of parallel vacuum workers. >> > > >> > >> > For now we have max_parallel_index_autovac_workers - this GUC limits >> > the number of parallel a/v workers that can process a single table. I >> > agree that the scenario you provided is problematic. >> > The proposal to limit the total number of supportive a/v workers seems >> > attractive to me (I'll implement it as an experiment). >> > >> > It seems to me that this question is becoming a key one. First we need >> > to determine the role of the user in the whole scheduling mechanism. >> > Should we allow users to determine priority? Will this priority affect >> > only within a single vacuuming cycle, or it will be more 'global'? >> > I guess I don't have enough expertise to determine this alone. I will >> > be glad to receive any suggestions. >> >> What I roughly imagined is that we don't need to change the entire >> autovacuum scheduling, but would like autovacuum workers to decides >> whether or not to use parallel vacuum during its vacuum operation >> based on GUC parameters (having a global effect) or storage parameters >> (having an effect on the particular table). The criteria of triggering >> parallel vacuum in autovacuum might need to be somewhat pessimistic so >> that we don't unnecessarily use parallel vacuum on many tables. > > > Perhaps we should only provide a reloption, therefore only tables specifi= ed > by the user via the reloption can be autovacuumed in parallel? > > This gives a targeted approach. Of course if multiple of these allowed ta= bles > are to be autovacuumed at the same time, some may not get all the workers= , > But that=E2=80=99s not different from if you are to manually vacuum in pa= rallel the tables > at the same time. > > What do you think ? +1. I think that's a good starting point. We can later introduce a new GUC parameter that globally controls the maximum number of parallel vacuum workers used in autovacuum, if necessary. Regards, --=20 Masahiko Sawada Amazon Web Services: https://aws.amazon.com