Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kxvJX-00039K-0g for pgsql-general@arkaria.postgresql.org; Fri, 08 Jan 2021 17:12:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kxvJT-0006oS-Ue for pgsql-general@arkaria.postgresql.org; Fri, 08 Jan 2021 17:12:35 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kxvJT-0006oK-Mm for pgsql-general@lists.postgresql.org; Fri, 08 Jan 2021 17:12:35 +0000 Received: from mout.gmx.net ([212.227.17.20]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kxvJR-0005sw-1O for pgsql-general@postgresql.org; Fri, 08 Jan 2021 17:12:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1610125950; bh=/MOsuksxbb41K1yNyv4HXXhHz6zDnBvAI/QFCXhR4fs=; h=X-UI-Sender-Class:Subject:To:References:From:Date:In-Reply-To; b=REcVhSDMMkD6CMrZR3EuqIhZP2lCaOBxOS+qIT4+RVaiSfgbIwgJSMinUHRUB5vMF 6gCWnX/s90mrq3sw39bic+akHVFPoPSA28mopCe2DGqy7SSFm1euKQOmGmqMUK0Amq ebLvmdeQ+oPeRiz2gMKTJ3zBVUXyjzNQsFnTeOsY= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.178.20] ([83.171.164.188]) by mail.gmx.com (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1Mjj87-1kESKz1FEJ-00lDrc for ; Fri, 08 Jan 2021 18:12:30 +0100 Subject: Re: Suggestion: provide a "TRUNCATE PARTITION" command To: Postgres General References: <99277f39-f1a1-6da5-176c-3def058cf568@gmx.net> <999c4e39-ec8d-35db-f77e-06361861fe4e@gmx.net> From: Thomas Kellerer Message-ID: <5f752f45-67ff-456b-5904-14b1782576bd@gmx.net> Date: Fri, 8 Jan 2021 18:12:30 +0100 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.21) Gecko/20090302 Thunderbird/2.0.0.21 Mnenhy/0.7.5.666 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: de-DE Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:oir3NsjusLl1h0vVQg0pRCjcy3lfUwwBAjtx067Qs6MCTZd4yOD Bn5Zc35p3NM/VgcefJWDeDaA0TXqM/x3QG2saATC5KnumMjgrs+vhFF0xaZ71unYlLq/hlz jcum/AcGZfIfWqNIEPt1NDAwHA9Y/kb7ht/cc4JgpPiGsKb8bqlt9aWG71cHr1s3U90lmXS 9s+DVZLfIAk9EcwVNvoIw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:Yz+TzmEagEw=:t1zGjmZo2tuwBkGe86BdMB IsVqB4QzFY+QLZjiz9AfEwjsYVZNXK0RywdVW+bqw9Ort6hMnQh3SAWI4lX59H7Rn2L8wpz8J r4Ox5xUk7x6+Qj2TusgzHfbKRB7QAmeWPEbYimPK2Y6DVE3uflNcihhBlBe/77zpwBJLZy/fi qmRT+vq66+ywcX6fdR/6jHahUPlqi8yGqpsJmzfUjj9/odQ2FnbiETBhEQN1cR/ogcB/eenm/ eOgxTK/U4wWzQgLOmqMZ7K6jqpAa6auKIM6ZscvVKfj84NlDy3/WJ9o0DrgTfVqAlFBR1rE4w Xyl7Qprb78P4aqvtN+qNDB0M2FhZfG8RsSZ+2DCtrOUdla2LrK6z8+F66GWuyz7/MoMab38xO Wuzd6DmaJDQDrhtLOqax826uD6Nu7bmzv4dpRBATxVz0WMwBWw5R+W+EPz4k34kdBXgO6TMwn Lc7/2U23dEMErGpzA1KXAHTI2ZjdjOImlRBC+PLj3HpsDXAZHHLRgv0ZgIRgs1e40qeqBuuUt esklEDQ4yVU5poEAx99N8jL0MhMTH3S52oFLqY1yuIVPWjT2TBgzpePE+rPIQzWC+PcCfADbY eQQJQcrBN34P4862fXaNBMIdO2842j4ZgBqRJpqf0HAJTGkhSmK+XQOcDAgA/I6EGYsnoudfB 7SPBPDtGsT0mfcu8iDis8b7k0NviWETe7TikKtH3UHin+KJ4w3NYLLNcFQk1FvuSgBaVfAYpQ RNn5UJkMH4T9uoRlPtRjqoRsX+1UiDdCNnsBvxbQE4D2uHo1X1CLH+3H43WRdjdBtKaefDUfA JFN6nY6Sk3pfbuplQ5562yqyJRC6mJV4toRMbDcwxEkd745ehKdbKM3AR+s0bLh9Hzm5DbRsh CcKmXptX7ZX6DgBauUag== List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Michael Lewis schrieb am 08.01.2021 um 17:47: > > For me, it seems too easily error prone such that a single typo i= n > > the IN clause may result in an entire partition being removed tha= t > > wasn't supposed to be targeted. > > I don't see how this is more dangerous then: > > =C2=A0 =C2=A0 =C2=A0delete from base_table > =C2=A0 =C2=A0 =C2=A0where partition_key in (...); > > which would serve the same purpose, albeit less efficient. > > > Delete has a rollback option, and you can dry-run to see impacted rows e= ffectively. Truncate does not. TRUNCATE can be rolled back as well.