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.96) (envelope-from ) id 1w78Ei-004zVk-10 for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Mar 2026 08:44:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w78Ee-002GMi-1o for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Mar 2026 08:44:36 +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.96) (envelope-from <3danissimo@gmail.com>) id 1w78Ee-002GMW-0N for pgsql-hackers@lists.postgresql.org; Mon, 30 Mar 2026 08:44:36 +0000 Received: from mail-yx1-xb134.google.com ([2607:f8b0:4864:20::b134]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from <3danissimo@gmail.com>) id 1w78Ec-00000001m7l-2qqN for pgsql-hackers@lists.postgresql.org; Mon, 30 Mar 2026 08:44:35 +0000 Received: by mail-yx1-xb134.google.com with SMTP id 956f58d0204a3-6501d32b04bso950801d50.2 for ; Mon, 30 Mar 2026 01:44:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1774860274; cv=none; d=google.com; s=arc-20240605; b=ZLDhVqnb/8nQ7vWDB9DFHOObe4L24nX63oXmaUbebOsiP+59etgDaMd8RweArSJPpc VXKN00UvooWSdgjdVXMkE/l6RwwOjPwhKA+AN4yuJUbHKW69Dpz1M3KvhEq4kdzAFzCn ImI5RUMtPU7o6o3hnPCF7s2Gx8YpjvrFRluIXTPwu/SwVSpLZbhKCSXcnAvuV1LGKb91 LA7Bd1mxVpxhJgtSITeF/fCcN2x/xqjVSRYsv4c7vs4PqfazvNUx0Pwn/a7gPphPHVzn RaGrgJbVBNT9T7kZBzRKoMzRDMv6LzU/aQxgf4RD6Q3ojmdeRqdja1cMAI46bkf5i/K3 L/Jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=lhge2jVO5sCFFcfmN/zvjpYTp8XmiPIWrmivJK9IgjA=; fh=difRtNqAw5Y6xkd0My/ewE68Nrx771LpqJv8FbgNc8M=; b=UniT5PIYlr+Sl0fD/n1xz9xtLkxNHlbd0Zoxpl4BkcJYac6DS1z0pWLa3T2GWQsZhX ywY3AS4DJXnS6fuEinVrvY6ZHQpw6rLx89DErEbIbudlD1pHKSWcAungO7i+lSDnowXy 9IfPBu/tmG6IDeCQW37aTe0Ki4ZMEKGrQhBpQUMqF5W0tfY3cqUoy29Hl/7pDE0RWuaX sRvR+meNzcMnqxv2G4wLTKSuFyhACOlW9wrVzN2/nNDLsrITXfDtKwfZYw9UEdPJwnop KOqoRi6lMoC6gS04p7WtkGpa6N686aikviUO/eMVs7LDf1Hb6R+LkWWxCpPRPnf/U9Kt XnAQ==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774860274; x=1775465074; 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=lhge2jVO5sCFFcfmN/zvjpYTp8XmiPIWrmivJK9IgjA=; b=IJp1kubPDoQc7gzcPVEB/Nwf8OnE7GMWSAtD4IkvZDjvzTXFE6ykfqKcf92u/d2L9X rKkoEEQMHuV0mhAzHkPwCeH6dL2gdu+QDQ3b2FprGKGKnjicCy9l3lEU1ogLfJ7kjKGo cySeNtzKFqRvPNDJYid/WJOkTC4uo49xi4zDnyeoX8HEdp7lZ1VxBs8iFy87m2pdA9aW RAJrowIgScGPHAt7oFRXDbNnqYcchz3DQnWDndG1LM4cmz5c0sRubj8HcH4ZKJI07+1N p/Ky7U3quN6pEI7Bf9C8gopHEDDRj+Fivxdf5ltAEiAgALrH7/47bVaqorIkjB/lauNU aUlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774860274; x=1775465074; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=lhge2jVO5sCFFcfmN/zvjpYTp8XmiPIWrmivJK9IgjA=; b=gnfBqG1sprLNH2THPMSpyKauwCuoCWatKIaxrAy0sVMX1FRphEQYK2R+TuOPEOyeps q1mlSQ2PhIB/xHALQCBreJbV2Joa4c3hAq7nVRSiQKlrUyUk8JUsDXu8SeNe+QlQwXaq yTZRRTvUjqrLymAmY3kPdPmWUzGlILxwSHU3KYbSEDla/H+B6Gkw91b5Vg7abZ2Z6GPy EQlCrtVkydRulanEMvNEmvOtzVB1K3IAUBShprusiX9ImjbTpcyir/QcWnZX76fgepbo I7vOXFRwTSrTBybPuSJEPwfwvm6ydUhnG+rMqv235AjG50i6VeT+SbiGcRwCNc+h26Uo YIdg== X-Forwarded-Encrypted: i=1; AJvYcCVs3SrmDEZ1l4YixLsha8jpqv4P+e7lpt4qNtWlF15o4OyjZsk2vIlz+pN9fL1SHqBc0qGg5kGV2fuDTHKU@lists.postgresql.org X-Gm-Message-State: AOJu0YyUwiDiJwgEOLMt5JNuWdxDqi381DeQht6Vt7JA8rdyA5S8uNcn rErKlf4FrT2KnI5+rgvuJfUcN5Ow/ttQk2U67rl6qhswd0WcDJD0AsC2kH3ay7VeQEJC9ntmFXD mFFM2qlcokFkYkVrAOUSWCV9zk0uODbw= X-Gm-Gg: ATEYQzxNGzp8Oky0jtFBQhNkogW11SJMI8g9MoAC6M2rlVY2D7K1ikgbY/afVKTjExz +dUNIiX2HcU08/ixtXDryMcu9nT+5hC/Pq0UsAQzjQ28/4T1Djdh+8qGktKsG0FY3Mh9mCzoZL3 521FlIacNntWXMvMtWw2EuiSuQj7d9yRjVQZ8/4lWRjbQwYeqF7Wsn8GBtRoqmkycMmw6Nvf4yj vYF1JF063lhTi1F9IY2Xgwx9ehraIzP79uhL+h7Z8uZphFfaEihuB7U4c6GzRITPj93RlxRzF2N opfWlAh/ X-Received: by 2002:a0d:dc87:0:b0:79a:b118:439f with SMTP id 00721157ae682-79bde072229mr89245407b3.50.1774860273891; Mon, 30 Mar 2026 01:44:33 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Daniil Davydov <3danissimo@gmail.com> Date: Mon, 30 Mar 2026 15:44:22 +0700 X-Gm-Features: AQROBzAl4eqnsEAPskbc51NlMofkQgxkM9vOKUFrZ8AXbkHi8Cv1KsKm1gMnSmo Message-ID: Subject: Re: POC: Parallel processing of indexes in autovacuum To: SATYANARAYANA NARLAPURAM Cc: Bharath Rupireddy , Masahiko Sawada , Sami Imseih , Alexander Korotkov , Matheus Alcantara , 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 Hi, On Mon, Mar 30, 2026 at 7:17=E2=80=AFAM SATYANARAYANA NARLAPURAM wrote: > > Thank you for working on this, very useful feature. Sharing a few thought= s: > > 1. Shouldn't we also cap by max_parallel_workers to avoid wasting DSM res= ources in parallel_vacuum_compute_workers? Actually, autovacuum_max_parallel_workers is already limited by max_parallel_workers. It is not clear for me why we allow setting this GUC higher than max_parallel_workers, but if this happens, I think it is a user= 's misconfiguration. > 2. Is it intentional that other autovacuum workers not yield cost limits = to the parallel auto vacuum workers? Cost limits are distributed first equa= lly to the autovacuum workers. > and then they share that. Therefore, parallel workers will be heavily thr= ottled. IIUC, this problem doesn't exist with manual vacuum. > If we don't fix this, at least we should document this. Parallel a/v workers inherit cost based parameters (including the vacuum_cost_limit) from the leader worker. Do you mean that this can be too low value for parallel operation? If so, user can manually increase the vacuum_cost_limit reloption for those tables, where parallel a/v sleeps too much (due to cost delay). BTW, describing the cost limit propagation to the parallel a/v workers is worth mentioning in the documentation. I'll add it in the next patch versio= n. > 3. Additionally, is there a point where, based on the cost limits, launch= ing additional workers becomes counterproductive compared to running fewer = workers and preventing it? I don't think that we can possibly find a universal limit that will be appropriate for all possible configurations. By now we are using a pretty simple formula for parallel degree calculation. Since user have several way= s to affect this formula, I guess that there will be no problems with it (exc= ept my concerns about opt-out style). > 4. Would it make sense to add a table level override to disable paralleli= sm or set parallel worker count? We already have the "autovacuum_parallel_workers" reloption that is used as an additional limit for the number of parallel workers. In particular, this reloption can be used to disable parallelism at all. > > I ran some perf tests to show the improvements with parallel vacuum and s= hared below. Thank you very much! > Observations: > > 1. Parallel autovacuum provides consistent speedup. With cost_limit=3D200= and > 7 workers, vacuum completes 1.41x faster (71s -> 50s). With cost_limit= =3D60, > the speedup is 1.25x (194s -> 154s). > 2. I see the benefit comes from parallelizing index vacuum. With 8 indexe= s totaling > ~530 MB, parallel workers scan indexes concurrently instead of the lea= der > scanning them one by one. The leader's CPU user time drops from ~3s to > ~0.8s as index work is offloaded > 1.41 speedup with 7 parallel workers may not seem like a great win, but it = is a whole time of autovacuum operation (not only index bulkdel/cleanup) with pretty small indexes. May I ask you to run the same test with a higher table's size (several doze= n gigabytes)? I think the results will be more "expressive". -- Best regards, Daniil Davydov