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 1uAIKN-00DR2X-VF for pgsql-hackers@arkaria.postgresql.org; Thu, 01 May 2025 01:03:04 +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 1uAIKK-00066m-JL for pgsql-hackers@arkaria.postgresql.org; Thu, 01 May 2025 01:03:01 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uAIKK-00066e-7o for pgsql-hackers@lists.postgresql.org; Thu, 01 May 2025 01:03:01 +0000 Received: from mail-lj1-x22b.google.com ([2a00:1450:4864:20::22b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uAIKJ-000RQl-0n for pgsql-hackers@lists.postgresql.org; Thu, 01 May 2025 01:03:00 +0000 Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-30bf3f3539dso5090821fa.1 for ; Wed, 30 Apr 2025 18:02:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1746061378; x=1746666178; 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=GgNJnK3FEOt5Z4l5lxrUSUUjJSUhCgZZucTyJ93b7a0=; b=EEx0BFDNxo2YtYOEq3rEfB9PCXXZflwBEn2/R2CSgbJWUOPDkClQkQ9j90OQ0OZ4bX 0HnG+efo0VkBfH7iyoXWYXexFGWtp+K/S1Y1/KtFxfuHJdtmUM8ahvRC7XqxIhQPPMvP HrRVlRTpBWKT7GODbhRm+kcxncOQK2RoGv5X6leOkE0kZO0p4KPy11VxNt4eWoPrXOLd vzuO6ebAIu9b5JhYpoQqhRxg1FHsekSwARR3N5TbTpcmtklSN5me9bITcdFi4REMsFu9 HKL5DbxMSY/mNQayC7q2coCf9126wlgyPf10DpdqnfJhAoI5ui1/IxuYa4oVtbZwNTm3 1OsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746061378; x=1746666178; 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=GgNJnK3FEOt5Z4l5lxrUSUUjJSUhCgZZucTyJ93b7a0=; b=UZnbSSxTkp4f/F4ngXIYTQ21XKlbSPpG9d7pRkLTcz7W4ZEEjRnfRyO62Dfr9glOth IkKbu1skwsYXLWYSdtIWllQ4sPg2LZE0szej8cgjdmcB16EAVDeMkUSkMGXbHHQ1T01i b7GrSfSE37rVeVKlHRAtZYKfpOWvJ3Rzpu43GZJ/2/AiyCnuLf2S2+AyGfZZFKqxv3Lw lVOuAbpyTK7XVKMCwZpA/br7BN/iMoNA/GDEdmoqQ+uXkJ20sXucbAoNnCuBJYStITPp YBOUzsxLIBUny3vUXyDiiRVWbGX3A708a3Y+XlWup6zxQDwUdNCo5eapXSQvwQj8oqhO FVxA== X-Gm-Message-State: AOJu0YyTmMvBTSAI07ASDvs+9nqU8AyZyl6WPWDwGPAQ6dFIDQEGOnIs vmZHyWd3g0RDK1QxmvZQ4yyB9AIeqh0efhsDFrXBqCa/Rg2w9SmCb6YjBJ+/oAB62OILGFwl46h tTxiwLPZCCQueuKhm9/F+9DeYf5c= X-Gm-Gg: ASbGnctF3x4fS6jngNB3r+FGorrjY00bghsK+SSYyNsXGIqDxmRmNuJTub7EZcekxwy z1QjQCiB280p4ZyFe3bboewj5We6xMgE/yxwswIvbAuwyHsWwA8plM6P3Mp5esFhGNW6pkPYFIf jids2Lz+BtvWgmAIrgxOveras= X-Google-Smtp-Source: AGHT+IFJpMHKSrCMY77hGKlIwoEsryppCeueffVKLm9KC9UaUnBXeTyoGluxXcTwnN72wtXWQDSJQlvgUOMkQg3JOx0= X-Received: by 2002:a05:651c:1506:b0:30c:1aa6:5565 with SMTP id 38308e7fff4ca-31fc16cab63mr1102111fa.20.1746061377462; Wed, 30 Apr 2025 18:02:57 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Masahiko Sawada Date: Wed, 30 Apr 2025 18:02:21 -0700 X-Gm-Features: ATxdqUGUCDrqIZ8pZHU-Lp8cgOPgw4VYEFiv65urXE9voKYoRmtSZ3ypyrNSN70 Message-ID: Subject: Re: POC: Parallel processing of indexes in autovacuum To: Maxim Orlov Cc: 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 Hi, On Wed, Apr 16, 2025 at 4:05=E2=80=AFAM Maxim Orlov wro= te: > > Hi! > > The VACUUM command can be executed with the parallel option. As documenta= tion states, it will perform index vacuum and index cleanup phases of VACUU= M in parallel using integer background workers. But such an interesting fea= ture is not used for an autovacuum. After a quick look at the source codes,= it became clear to me that when the parallel option was added, the corresp= onding option for autovacuum wasn't implemented, although there are no clea= r obstacles to this. > > Actually, one of our customers step into a problem with autovacuum on a t= able with many indexes and relatively long transactions. Of course, long tr= ansactions are an ultimate evil and the problem can be solved by calling ru= nning vacuum and a cron task, but, I think, we can do better. > > Anyhow, what about adding parallel option for an autovacuum? Here is a PO= C patch for proposed functionality. For the sake of simplicity's, several G= UC's have been added. It would be good to think through the parallel launch= condition without them. > > As always, any thoughts and opinions are very welcome! 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). 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. Once we have parallel heap vacuum, as discussed in thread[1], it would also likely be beneficial to incorporate it into autovacuum during aggressive vacuum or failsafe mode. 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. 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? Regards, [1] https://www.postgresql.org/message-id/CAD21AoAEfCNv-GgaDheDJ%2Bs-p_Lv1H= 24AiJeNoPGCmZNSwL1YA%40mail.gmail.com --=20 Masahiko Sawada Amazon Web Services: https://aws.amazon.com