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 1uAuti-003vNl-SI for pgsql-hackers@arkaria.postgresql.org; Fri, 02 May 2025 18:14:07 +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 1uAusi-00Ahne-CM for pgsql-hackers@arkaria.postgresql.org; Fri, 02 May 2025 18:13:05 +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 <3danissimo@gmail.com>) id 1uAusi-00AhnV-36 for pgsql-hackers@lists.postgresql.org; Fri, 02 May 2025 18:13:05 +0000 Received: from mail-yb1-xb29.google.com ([2607:f8b0:4864:20::b29]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from <3danissimo@gmail.com>) id 1uAusg-000kB9-1p for pgsql-hackers@lists.postgresql.org; Fri, 02 May 2025 18:13:04 +0000 Received: by mail-yb1-xb29.google.com with SMTP id 3f1490d57ef6-e756416045bso1258036276.2 for ; Fri, 02 May 2025 11:13:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1746209580; x=1746814380; 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=y2rZN0gKZH00CXWhxq4s7ukfMRMvbGgKm/d3+HBsEUI=; b=PSHyw7ecGydrKL9NQtj3xYDg/TOiCpfq/RyuWcKg5VyJ9O9LdH+OUor1D2AavC+RG1 BMiy0AQEDSNIRyPBc0BuQ1/0OAmkKx9CRB1yLePHuX6zRGNCMdGmwUZdkopNU7N0UNGm nl4lKMdek39w1eAcXJEQYUUQgFs0pkizpmYePjZ8QX+YHHJXzgzP0id2kyqWgTnFUjJa xBRyJJ7Z/QsK5nj3eiFazpdPwXam4e2v2yuCcbKZApBKYna0ElKjvlKiA2jPR4EPbCeU Foa2bSKMjkVo+4Y71g5bYUOxMM7BLsIVFGcRRPnXG1Jz9GIZeHGDQJFLXARV+IPoKejE Vj1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746209580; x=1746814380; 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=y2rZN0gKZH00CXWhxq4s7ukfMRMvbGgKm/d3+HBsEUI=; b=Wq3Pq0nEq0o/w/RJRFMPNk4uDCZFR9Vp002gl76Ixi4M1nc6nlsYumb/DJvFkFW0Fa Mfm9uUDlzXPxLTZcVmU6AV33weSh+vqBEIQjyEJDiZz9XGb38kr1h/tIAAk0QP6Y2UtR 2Ctxyok2dI/zJaTjcKZi5WfWhZK8XnJXReCR1iDinvknrH81woJ2IxgfvnYr8qMIiXhJ WMR4bHGtj+1GIjYOUW/kISCiavwp+hHv9GFUnrAAfClzPwBtb+Imo2L1C2m7w73pwwMk DQkmlDrOGOjIElGYnZJo7XVoscbtFX+ftgL30XD1C2Rz91ghPCKGTlL8kN/XYhYMe5lt tkUg== X-Forwarded-Encrypted: i=1; AJvYcCXOwM1qAaUizkxiricBXtIiA3puhl6RYapE3l1zMRr8uIdC7xXmC2yGyHpEwDKEw7MA6cRYTtjJ4RK8zCWN@lists.postgresql.org X-Gm-Message-State: AOJu0Yxi4MthgBZOovg4C0CpG0LjAZbK63zqLtHrk8x6BwJXz/tyoJ+5 09zwCYLKPTB4rMLvQjLaHjJr7VXDWo/iViSW0TXHThS6re3qg4oQuE1cDq01wVqf3YSoikFfXnw o6d+wM93YEmkyMPLm6XOPwZymqdU= X-Gm-Gg: ASbGnctn30utp+aDzb0+6TWfxLuRV/Pa8ZBAyAQ0zW/DmVzSYt304nPJNZompceMggF zLAntKrqW8wRhQtC1hEr1KGZ24epLSKueACwY8DZIn0hSkJYZ6uC+H10CcjvxNfE6sGyG5H+FEa ER3F33mqu8c2JBcMDDUclCRDQ= X-Google-Smtp-Source: AGHT+IGf+/qzIojvqE/F6FkC/YZXlFGwlSGF/FNzdk62mgU0qKWnKFeaq97ov9NfopcEOcMZlF+q8+izaqgnc1nkHzk= X-Received: by 2002:a05:6902:1b09:b0:e73:825:52eb with SMTP id 3f1490d57ef6-e756565602bmr4811227276.41.1746209580369; Fri, 02 May 2025 11:13:00 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Daniil Davydov <3danissimo@gmail.com> Date: Sat, 3 May 2025 01:12:49 +0700 X-Gm-Features: ATxdqUEb9AOiRaw4hFpNd-Bv7EwfAs881teaPs5E-ZVPe1oM9kGAYavUIHT_zok Message-ID: Subject: Re: POC: Parallel processing of indexes in autovacuum To: Masahiko Sawada Cc: 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 Thu, May 1, 2025 at 8:03=E2=80=AFAM Masahiko Sawada wrote: > > As I understand it, we initially disabled parallel vacuum for > autovacuum because their objectives are somewhat contradictory. > Parallel vacuum aims to accelerate the process by utilizing additional > resources, while autovacuum is designed to perform cleaning operations > with minimal impact on foreground transaction processing (e.g., > through vacuum delay). > Yep, we also decided that we must not create more a/v workers for index processing. In current implementation, the leader process sends a signal to the a/v launcher, and the launcher tries to launch all requested workers. But the number of workers never exceeds `autovacuum_max_workers`. Thus, we will never have more a/v workers than in the standard case (without this feature). > Nevertheless, I see your point about the potential benefits of using > parallel vacuum within autovacuum in specific scenarios. The crucial > consideration is determining appropriate criteria for triggering > parallel vacuum in autovacuum. Given that we currently support only > parallel index processing, suitable candidates might be autovacuum > operations on large tables that have a substantial number of > sufficiently large indexes and a high volume of garbage tuples. > > Although the actual number of parallel workers ultimately depends on > the number of eligible indexes, it might be beneficial to introduce a > storage parameter, say parallel_vacuum_workers, that allows control > over the number of parallel vacuum workers on a per-table basis. > For now, we have three GUC variables for this purpose: max_parallel_index_autovac_workers, autovac_idx_parallel_min_rows, autovac_idx_parallel_min_indexes. That is, everything is as you said. But we are still conducting research on this issue. I would like to get rid of some of these parameters. > Regarding implementation: I notice the WIP patch implements its own > parallel vacuum mechanism for autovacuum. Have you considered simply > setting at_params.nworkers to a value greater than zero? > About `at_params.nworkers =3D N` - that's exactly what we're doing (you can see it in the `vacuum_rel` function). But we cannot fully reuse code of VACUUM PARALLEL, because it creates its own processes via dynamic bgworkers machinery. As I said above - we don't want to consume additional resources. Also we don't want to complicate communication between processes (the idea is that a/v workers can only send signals to the a/v launcher). As a result, we created our own implementation of parallel index processing control - see changes in vacuumparallel.c and autovacuum.c. -- Best regards, Daniil Davydov