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 1vl7dn-007OIb-2i for pgsql-general@arkaria.postgresql.org; Wed, 28 Jan 2026 15:39:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vl7dm-0027i8-31 for pgsql-general@arkaria.postgresql.org; Wed, 28 Jan 2026 15:39:35 +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.96) (envelope-from ) id 1vl7dm-0027hx-20 for pgsql-general@lists.postgresql.org; Wed, 28 Jan 2026 15:39:34 +0000 Received: from mail-oa1-x33.google.com ([2001:4860:4864:20::33]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vl7dk-00000000tht-2H6x for pgsql-general@lists.postgresql.org; Wed, 28 Jan 2026 15:39:34 +0000 Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-4044d3ff57bso1971364fac.0 for ; Wed, 28 Jan 2026 07:39:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1769614770; cv=none; d=google.com; s=arc-20240605; b=JI1J0O4pyWLP8XA1hhayNn+arC2oJg/7KUVBn7HFh9qUMQzkGxqW8B5oatxuyYFgUF VEyU5uW1GKThYWhXLEw72hWweorcQVk9pwjRUK54nU6iLsI3zXKjLuAyER7WRbVMPc2f SrdQ9FQcexSHKEghYSWA3+ckN9hg5/I1lRIzDg72UzpeFN3gG08wZWOyAWKaa1LpDrAR ho4eMXtY2hhc1hVBbqCCpWw/zhOiDVJBOAwy2pvumMcCOxkOcMCIr72tBxrdJ5kKmTw5 kNRXu9xVIrmr/DcX0210+TTyOvBmsrIfRtnhhN9sdcnbqEJ1LaPfJnfKG7fMHETIYZgu 7EDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=I4UIAod/OfwMZJDRsvVOu6RyUt3ki6fCRQFvoqeGL5w=; fh=b9Uzbyz7PRtDWT7w+MvRen0wUjno7OZfj/y0ozIuvj4=; b=Yq0gewQwrwHmuBu6iRz54UNcM6hiOA/Z7iFIuqVKFHFmLKUE+MUmxtKP6wegg4kF/T XH7dn0+AxiObfobsfSUSNKH0giB1MedvCsZQtyf6stPQkoVuQLOb9+jJ/Mlfhl0jvQhz AdQ1znfhFDQAi2v5FvJrXjhN1AW21rr1jkH2RklHTDuJJJCllPVaL2GYgoQWz8YHA64C rFSM0hyBdHXlT9it2jrpWtlSf6fFqMuylvbUEJDERJrONje8x/SCXipqZt8sVtIqVx6M ec6xLhgZPaEwFiZJXGojD/CMyK7yyztrOE31X3RPSuBqBATI4qjKdB3tmGYGv2LHYa6h 7/zg==; 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=20230601; t=1769614770; x=1770219570; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=I4UIAod/OfwMZJDRsvVOu6RyUt3ki6fCRQFvoqeGL5w=; b=AaEG9BRUdh0vaX5a+5Te4B2uzVXQijCV6KrhKjvv7TCS4rd8FS6HW5EVxBf24Q9PCQ BTJVi9Ww8h1fO2w8am9WSvWjVyYhTA7M8UCRu2UJzCyaWAt3/6l675uyLOB026nI5Z2j HAExTXqXZfjN9jwmm4OHhb95XnNwUOyKdhc31tPN5ZSZxxt0uS3fVT5S4GQvcbPSD86N CUOVkVDA/6SIJGytkf1rBSS13xyGf06PUqtoI2gX6hnTotKAQOY+0s4QbuqDRAdrf5z4 WYez79flg+o+Z1WeATt4MEKNbqA9Y0XY4ugWyqw9QSdSWONX0PEQwvptIkjqwMN3Fr2b KR7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769614770; x=1770219570; h=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=I4UIAod/OfwMZJDRsvVOu6RyUt3ki6fCRQFvoqeGL5w=; b=Lzku9fb600cZqf+aaZPjm+NFR5YLlbquxDuQ/6FUgikqO22NRg2aFgLJaMJl4fWLq0 fL8oUpZaRzlbjiNl3fnrRJDFqM45MBMfrmiiM7a4xW/2hl6OMhFzCiHAYcCW8C4K+0ul OjcJpTOo/YARvUWR8mkTJhU/eqAP1fWB8cIc/fK58VIOBFjZymegvYac/oczvhqI5urK Dwn71RVR9IKMdx0CxkeKl1xScef2u9p0S7zxS8RZPyAzq+n1dyEwsyS4fbzJUcwxSWpK 0is6JgdAzx491h/d3HKbH03MSJ+Xy26j8RXR11g32j20Rbio6+tdtwnZ0JSkLgPgkS++ zqvw== X-Forwarded-Encrypted: i=1; AJvYcCXh3u6DdGwXpN7fQBEOhRneU2xtsuleWddHAR6CrTiDH1aYL13P3kp1zzH9thRKtdjc1LLsFyqKCFXHLgRJ@lists.postgresql.org X-Gm-Message-State: AOJu0Yzv8wq02+3ZttTrW8cMGwVSiua3/vddEE1gz48BOpUbc2G2h7xP FiF8n8fXWaJwSe31vTdr7nGf94KN4b5mZco3HsOuK1Sd197hqtTLLJ+m2RX+oUfJ7lKET2w2HaW XvqbuLxUVIm6AbDK/DemkUOC4v50tuq8= X-Gm-Gg: AZuq6aK9e/cvf2FZ1ZKuzx4x7EYwhe3npqT1ND+Qdw1U3Zh4m9F8N5rTTM63UsuTVx8 g1dt1SjWx38kb3GILmJlKN1F4dkc1f8LuYH3UQo0TlpQXU8+NRMZqj33Jfv4IU4J+o+JrfS3wML bx3e/GAX1LxFpw0U5ayX0gT//v258iuVttC1qRLeOT8CqBvHcnVH8KTewD1aQlawiIFEP48sKew /KTQoiZLJBhhR5rxRzUvuZOts1QqODEyu0l4scKXjY3XU40aYSEtJAIFoHQPSsSzBHnttV0H/oH TD8k9eDe+PifnfEnPyb06vp010GYpw== X-Received: by 2002:a4a:ddd2:0:b0:662:f543:5d42 with SMTP id 006d021491bc7-662f543638emr2289993eaf.77.1769614770075; Wed, 28 Jan 2026 07:39:30 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Greg Sabino Mullane Date: Wed, 28 Jan 2026 10:38:53 -0500 X-Gm-Features: AZwV_QiD0dxAJ2uxJ2wLnbLZnwfHZnm1ik3OBpFR1UrgpWRLDVTDzO7gxBmsDQg Message-ID: Subject: Re: Attempting to delete excess rows from table with BATCH DELETE To: "David G. Johnston" Cc: Gus Spier , pgsql-general Content-Type: multipart/alternative; boundary="000000000000c27bcd0649748bd7" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000c27bcd0649748bd7 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Jan 27, 2026 at 10:31=E2=80=AFPM David G. Johnston < david.g.johnston@gmail.com> wrote: > Strongly encourage you to try to accomplish your goal without any delete > commands at that scale that causes vacuuming. Can you just create an emp= ty > copy and load the data to keep into it then point at the newly filled > database? Truncate is OK. > This is really the best solution, especially if most of the rows are > 75 days old. This removes 100% of your bloat, allows you to keep the old data around in case something goes wrong, reduces WAL compared to massive deletes, and removes the need to mess with autovacuum. Cheers, Greg -- Crunchy Data - https://www.crunchydata.com Enterprise Postgres Software Products & Tech Support --000000000000c27bcd0649748bd7 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Tue, Jan 27, 2026 at 10:31=E2=80=AFPM = David G. Johnston <david.g= .johnston@gmail.com> wrote:
Strong= ly encourage you to try to accomplish your goal without any delete commands= at that scale that causes vacuuming.=C2=A0 Can you just create an empty co= py and load the data to keep into it then point at the newly filled databas= e?=C2=A0 Truncate is OK.

This is real= ly the best solution, especially if most of the rows are > 75 days old. = This removes 100% of your bloat, allows you to keep the old data around in = case something goes wrong, reduces WAL compared to massive deletes, and rem= oves the need to mess with autovacuum.


<= div>Cheers,
Greg

--
Enterprise Postgres Software Products & Tech Supp= ort

--000000000000c27bcd0649748bd7--