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 1sTaEr-000BsJ-Lv for pgsql-general@arkaria.postgresql.org; Tue, 16 Jul 2024 04:56:33 +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 1sTaEq-00FNxK-BB for pgsql-general@arkaria.postgresql.org; Tue, 16 Jul 2024 04:56:32 +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 1sTaEp-00FNxB-TP for pgsql-general@lists.postgresql.org; Tue, 16 Jul 2024 04:56:31 +0000 Received: from mail-oo1-xc31.google.com ([2607:f8b0:4864:20::c31]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sTaEi-002HZs-V5 for pgsql-general@lists.postgresql.org; Tue, 16 Jul 2024 04:56:30 +0000 Received: by mail-oo1-xc31.google.com with SMTP id 006d021491bc7-5c669a0b5d1so2800528eaf.3 for ; Mon, 15 Jul 2024 21:56:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721105784; x=1721710584; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=J+VX+WpZetYvIk0NPq2eX0XrjMq9ckUO28lMklHQv94=; b=mPziORTvGCG7DLmSQy4VJ9Aep4JCVo5Xb+NEUWFOcfEEBOiFTv39sUOeu5nqiuLnZn ug7xax5ghyPuOTX7Jtp7jGkA4tb3XgHMEZ/udxf2asQ6wrrnLVFCwzS1ihcKGQZydxUw 4uDVijhMk3PxHJo9ehyBeKYl9QkrSt3zxEkbfxrcfWC1eMHXVXpAgD2+j+ygwATkTrm8 49l3gCjGFp+gmtTXOEyPPZ7w9NE2K/LmCaZOmTtsAIBoygVCPxRU5Hde28hLQnl1Ey/7 YwlNVzjj+KXDeSOPxfaWSlz+jmcI9+Xqw/1sR/DoGAy5Gu/Ad1ufHal0k0Cm7fDIUfah 6DxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721105784; x=1721710584; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=J+VX+WpZetYvIk0NPq2eX0XrjMq9ckUO28lMklHQv94=; b=UI3rhB4bDR6TfChVrah9ho9UTvnwjwOPEg1unkRdIylhjCDz7z3rT2nQKvYmmYRe2L dUSG7jrHk+V1mhypXf6KWh9cek+nCsLt92ic3wU3qER9MGSEh6Q5BHgwHWqY2PZETG03 L990+bknyGBdSOwhw2xgM4DiU2kk7gQAuobRhhxR/KBdYgSP62o+iBKO4UyHoRu/B7Hw qcqMFH+aBcfNfaRB2SxAfV7ptfqZvTapF2jTQdqWu8g/tBn8YDJhwEl59kxGGmbnJie/ BO6LOw+ht+fB/a6BA3GV5W2kpMGemKP7FhkxqQNUf6D05EG5LzoyYWIyAj+JNm1SeQ6V kEcg== X-Gm-Message-State: AOJu0YyDPTtZTw4Yy5dVaDyMtNgw0h79YtL7lC+iG9wYFKIifPdNFOE/ z5mvCll4Y52QjtdhAUq0vkrP+HibGw+v6Vr/pfsFdTBLWh/XDh3Znsze+G4vWpbFwrAtOmKGRPc DxJKTE2ooDhJ6HZwcd8k+YXL0XmKYgg== X-Google-Smtp-Source: AGHT+IHMnMRCJXz0Ze12yq3fedzcIpDY/fjfeCI4K+aEeuiLCU9VfMOHd1sP8xj1gL5hZ/w1YfIKb9TMRxcSqRpK/8E= X-Received: by 2002:a05:6820:3082:b0:5c6:5cc9:bf29 with SMTP id 006d021491bc7-5d2891334e0mr1164868eaf.5.1721105784223; Mon, 15 Jul 2024 21:56:24 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ac9:760a:0:b0:539:aa10:6c7 with HTTP; Mon, 15 Jul 2024 21:56:23 -0700 (PDT) In-Reply-To: References: <20240713220545.cgjghaggksov3xkt@hjp.at> <20240715142744.7e7a3wtdfxinochf@hjp.at> <20240716003731.m75sye7qq74wadhe@hjp.at> From: "David G. Johnston" Date: Mon, 15 Jul 2024 21:56:23 -0700 Message-ID: Subject: Re: Dropping column from big table To: sud Cc: "pgsql-general@lists.postgresql.org" , "Peter J. Holzer" Content-Type: multipart/alternative; boundary="000000000000e3bf5f061d562a1e" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000e3bf5f061d562a1e Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Monday, July 15, 2024, David G. Johnston wrote: > On Monday, July 15, 2024, sud wrote: > >> >> However even with "vacuum full", the old rows will be removed completely >> from the storage , but the new rows will always be there with the 'dropp= ed' >> column still existing under the hood along with the table storage, with >> just carrying "null" values in it. [=E2=80=A6] Is this understanding cor= rect? >> > > No. The table rewrite process involves creating new tuples that exactly > conform to the current row specification. The potentially non-null data > present in live tuples for columns that have been dropped are not copied > into the newly constructed tuples. > > https://github.com/postgres/postgres/blob/d2b74882cab84b9f4fdce0f2f32e89 > 2ba9164f5c/src/backend/access/heap/heapam_handler.c#L2499 > > My bad, stopped at the code comment. Apparently the data is just nulled, not removed, the current row descriptor contains those columns with =E2=80= =9Cis dropped=E2=80=9D and since this behavior doesn=E2=80=99t change the catalog= s in this way the new ones must as well. We just get the space back. David J. --000000000000e3bf5f061d562a1e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

On Monday, July 15, 2024, David G. Johnston <david.g.johnston@gmail.com> wrote:
On Monday, July 15, 2024, sud <suds1434@gmail.com> wrote= :

<= /div>
Howev= er even with "vacuum full", the old rows will be removed complete= ly from the storage , but the new rows will always be there with the 'd= ropped' column still existing under the hood along with the table stora= ge,=C2=A0 with just carrying "null" values in it. [=E2=80=A6] Is = this understanding correct?

No.=C2=A0 The table rewrite process involves creating new tuples tha= t exactly conform to the current row specification.=C2=A0 The potentially n= on-null data present in live tuples for columns that have been dropped are = not copied into the newly constructed tuples.



My bad, = stopped at the code comment.=C2=A0 Apparently the data is just nulled, not = removed, the current row descriptor contains those columns with =E2=80=9Cis= dropped=E2=80=9D and since this behavior doesn=E2=80=99t change the catalo= gs in this way the new ones must as well.=C2=A0 We just get the space back.=

David J.
--000000000000e3bf5f061d562a1e--