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 1to4za-005jYi-I6 for pgsql-hackers@arkaria.postgresql.org; Fri, 28 Feb 2025 18:21:47 +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 1to4zb-00CT0Q-Im for pgsql-hackers@arkaria.postgresql.org; Fri, 28 Feb 2025 18:21:46 +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 1to4zb-00CSzA-8e for pgsql-hackers@lists.postgresql.org; Fri, 28 Feb 2025 18:21:45 +0000 Received: from mail-io1-xd34.google.com ([2607:f8b0:4864:20::d34]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1to4zX-000DKh-2i for pgsql-hackers@postgresql.org; Fri, 28 Feb 2025 18:21:44 +0000 Received: by mail-io1-xd34.google.com with SMTP id ca18e2360f4ac-855b09fca35so168450339f.3 for ; Fri, 28 Feb 2025 10:21:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740766903; x=1741371703; darn=postgresql.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=QR8lp+Z8BWGMXatZN+5++2gz+SQFUoo5vuILFZ2zgv8=; b=QXIdvvcLu7klLwZ43J3+fNEWdwvmI/PC2ByKi4pHutwDQF8524htjLqtYH+OUtc1JI z6f4cPDXqSYwMqNxNMPIvTvrGuvVJCWy+wvw3XAIHYDKYSTUqXIzsptbryHtqjCWvCk0 mjQEJvrqGZPK5QMR2wNXyIWPAraHpvotK2G+8RzhrPGfjsqnvCpD0c1L3uo0rZu6AKdz fT2i+ZXQKRMh6MgeRsXR2KRiQxpu08D8mPxMMpvYfIGSBYwYfM60IOEmVgIp8hTRdon/ nr4o1PXNDhUWote4jSM3LX9LkWHtqyo9EhrT86xN5T/0lhP+7Ux+2a8pFxntmqa/APIR 7GFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740766903; x=1741371703; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QR8lp+Z8BWGMXatZN+5++2gz+SQFUoo5vuILFZ2zgv8=; b=k3CdLJoh+E6qhsosmCxCbabAZ/VFL9YRX/M/gvOCyFKQKTowPWgqzpjQ+wJhNGqIXr g6kmZNW+tU8rstm9o9zuEoM+pwXHcxmVI41CxEHJ+bZvzwusEINSt/DLdnmprKHGrpj7 UcF51KP1lDl8O1kdWJDkx5f5kG38eimAbNcSqYfklUcaOjCe9jfM2Szx9/Xv+ITHp8+i f0bBDnFJBYEV8DMplf4+niBPQSiVUCOl2PH5vZU4TgyGfckxjYicotYy6jm8/JUsb3sE uU6qIutNiYAeLZL9D6EgYtPUv7uIij/+d6gKSwd8F017FMvaAYeaRUE8MMRYKqFQCdkH qhhQ== X-Forwarded-Encrypted: i=1; AJvYcCXQv7CuEGqMq5P5IJ2FWAuTd+rzDhQEuZ06SdHDsA3BGn5PQf+wSNe98Oa35U6YuitL6btyoMlAgfR0SMs/@postgresql.org X-Gm-Message-State: AOJu0YwetksYNcJbJBMVA7stwaxvojiCKJjBZNRY/mz7ikLX4g60MMJU tLf/YM1M4qXc+hmuh82KDSOURh6aZbo2pEJ2nHt096GZCff+VPPu X-Gm-Gg: ASbGncv+CrDPPwbl9Bu+GbDYj6kn/CjeD67hsQUh0b6AhSNt0Ib+SYqDeIZfa7UFN8S Tx8Y9g6FDmUyY5IN4Lon4XMYn0uO2jo+/YF8Ine1CayyNuGJ0wOlhhAycyUD/p6l381e0JrgI8c Cc08zuYVAjD+v82bQReWYbbeMAs8d4pbbE6Dpd9jK9Q02uVE9hzB6zn7iCZvSiIEEL/sasnyKUt 45QE7eZW/WRivfsAIOgHB8AtuCipqZOyaXQUFcXG2ZGJd/AdHuI9omP+3lCdCk3mJZGGvDElW/8 Scpbr9gAMnUPd2qDfDgesTNTojsH4iyrqAsjVNG6yLGGJcN4b7h9i4aovWmPLYpqopACtnteg9h qgpZ6Eg706f4QxbB6 X-Google-Smtp-Source: AGHT+IHiLXK5YgsFm0TnboHgBnBd8lUeKxZgAzBrVf8Nu0DO5S68nI/6VFPl+Q85T0eVDU4CqGo/8g== X-Received: by 2002:a05:6e02:1cad:b0:3d1:9429:e5bf with SMTP id e9e14a558f8ab-3d3e6fae5bcmr50245445ab.19.1740766903106; Fri, 28 Feb 2025 10:21:43 -0800 (PST) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-3d3deee5121sm9614195ab.65.2025.02.28.10.21.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Feb 2025 10:21:42 -0800 (PST) Date: Fri, 28 Feb 2025 12:21:40 -0600 From: Nathan Bossart To: Gurjeet Singh Cc: Robert Haas , Laurenz Albe , Postgres Hackers , Will Storey Subject: Re: Disabling vacuum truncate for autovacuum Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Feb 27, 2025 at 08:29:16PM -0800, Gurjeet Singh wrote: > On Mon, Jan 27, 2025 at 1:55 AM Laurenz Albe wrote: >> I hope it is possible to override the global setting with the "vacuum_truncate" >> option on an individual table. > > Current patch behaviour is that if the autovacuum_vacuum_truncate is false, then > autovacuum will _not_ truncate any relations. If the parameter's value is true > (the default), then the relation's reloption will be honored. > > A table-owner, or the database-owner, may enable truncation of a table, as they > may be trying to be nice and return the unused disk space back to the > OS/filesystem. But if the sysadmin/DBA (who is ultimately responsible for the > health of the entire db instance, as well as of any replicas of the db > instance), > wants to disable truncation across all databases to ensure that the replication > does not get stuck, then IMHO Postgres should empower the sysadmin to make > that decision, and override the relation-level setting enabled by the table- > owner or the database-owner. IIUC reloptions with corresponding GUCs typically override the GUC setting, although autovacuum_enabled is arguably an exception. If setting the GUC to false overrides the relation-specific settings, it also becomes more difficult to enable truncation for just a couple of tables, although that might not be a popular use-case. Furthermore, even if we do want the GUC to override the reloption, it won't override VACUUM (TRUNCATE). >> > One additional improvement I can think of is to emit a WARNING or NOTICE message >> > that truncate operation is being skipped, perhaps only if the truncation >> > would've freed up space over a certain threshold. >> >> Interesting idea, but I think it is independent from this patch. > > Agreed. I'll consider writing a separate patch for this. Perhaps it would be useful to say whether truncation was attempted in the output of VACUUM (VERBOSE) and the autovacuum logs. >> > Perhaps there's value in letting this parameter be specified at database level, >> > but I'm not able to think of a reason why someone would want to disable this >> > behaviour on just one database. So leaving the parameter context to be the same >> > as most other autovacuum parameters: SIGHUP. >> >> I can imagine setting that on only a certain database. Different databases >> typically have different applications, which have different needs. > > Makes sense. I don't think anything special needs to be done in the patch to > address this. Hm. I was thinking PGC_USERSET might make sense for this one, but that was only because I didn't see any technical reason to restrict it. I don't know whether limiting it accomplishes anything beyond making it more cumbersome for users to choose their desired default truncation setting. > PS: Nathan, your latest email arrived as I was preparing this email and patch, > so this email and patch does not address concerns, if any, in your latest email. > I will try to respond to it soon. Oops, sorry for the conflict. I'm happy to take a step back and be the reviewer/committer for this one. -- nathan