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 1sTMgF-00FU7m-Qq for pgsql-general@arkaria.postgresql.org; Mon, 15 Jul 2024 14:27:55 +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 1sTMgD-00AXB1-L6 for pgsql-general@arkaria.postgresql.org; Mon, 15 Jul 2024 14:27:53 +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 1sTMgD-00AXAt-9J for pgsql-general@lists.postgresql.org; Mon, 15 Jul 2024 14:27:53 +0000 Received: from mail.hjp.at ([212.17.106.138] helo=rorschach.hjp.at) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sTMg7-002Aym-8x for pgsql-general@lists.postgresql.org; Mon, 15 Jul 2024 14:27:52 +0000 Received: by rorschach.hjp.at (Postfix, from userid 1000) id 49F6019075; Mon, 15 Jul 2024 16:27:44 +0200 (CEST) Date: Mon, 15 Jul 2024 16:27:44 +0200 From: "Peter J. Holzer" To: pgsql-general@lists.postgresql.org Subject: Re: Dropping column from big table Message-ID: <20240715142744.7e7a3wtdfxinochf@hjp.at> Mail-Followup-To: pgsql-general@lists.postgresql.org References: <20240713220545.cgjghaggksov3xkt@hjp.at> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="cz2bpzg3kw4qj275" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --cz2bpzg3kw4qj275 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2024-07-15 13:53:25 +0200, Laurenz Albe wrote: > On Sun, 2024-07-14 at 00:05 +0200, Peter J. Holzer wrote: > > On 2024-07-11 10:06:47 +0200, Laurenz Albe wrote: > > > Dropping a column is fast, but doesn't reclaim the space. > > > VACUUM won't block anything, but won't reclaim the space. > > > VACUUM (FULL) will block everything, but will also not reclaim the sp= ace. > > >=20 > > > You'd need to use a form of ALTER TABLE that rewrites the table, > > > as indicated in the documentation. > >=20 > > Unfortunately the documentation indicates very little. It mentions that > > the table will be rewritten with > >=20 > > * SET ACCESS METHOD > > * a volatile DEFAULT > > * changing the type of an existing column (unless binary coercible) > >=20 > > All three change something which you probably don't want to change. >=20 > Hm, true. >=20 > You can always do >=20 > UPDATE tab SET id =3D id; >=20 > followed by >=20 > VACUUM (FULL) tab; Yes, that should work. It needs about twice the size of the table in temporary space, though. Since the OP wrote that the table is "daily ... and 90 partitions" (which understand that there is one partition per day and partitions are kept for 90 days) it might be better to just wait. After 90 days all the partitions with the obsolete column will be gone. hp --=20 _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp@hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" --cz2bpzg3kw4qj275 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAmaVMdsACgkQ8g5IURL+ KF1R9w/+IFec+DjbWH1pBnQdRPpEeGy4CsNDd6noH0uSaxlgwiXdzURhb6GjObw8 tDQsLv7hvhNIgHxBB9Btk8atykkO927hVyHwJqd4bxqQfeB+weMzboe4z4+fdZk5 0LHfA8lGMBhmQRit1xdGRh+sBtGw9IPSCsaGg5BvTm0WP4DXbXJbphYpy64ccoM9 w5rqcaedQ1ERhHddoA7ASjHxZSxDCMpojROWOl2D0y3XAQXemd/Y0DWFsKLyGIun zes7xjx+x9Ewz1GfC9sxBoTWCsikAI9jQjEdQYfQcGJM5j51A5z7EhRXIYyRF6Js KfIL2Hda+gTgkI1acOLNqXBPa/fEnoHAgMJGKntQTwoIomtjLW7mKHctxC5Odjko YqehTLUtKFD8wesdaeANQOZch75O+BQF0yRt9J3aLvksF4H4FhAXLmP1uWboDgO4 mdzsin7vzWCimLcKqycA5GPUs2Cw7TSIETLA12QWzL215Qt0+soVjJ6ld8935C6H LbVj105vPX4yTVTStHXAzKSvHAjHIjEq8U08WH2QV05X2EPQLmWausi5XZBt3QnB eBgMqvwN4r/mqq5zI8Rug0hvXDVlkbNjQXsSqVE66LF+DoKCgB4cn644qUtLwCoM gIFAD2qRxJhyHMhnPLDripGfCcC6kKVwKD17gvd2d4DMoppHvBg= =3QOr -----END PGP SIGNATURE----- --cz2bpzg3kw4qj275--