Re: [**EXTERNAL**] Re: [pgsql-admin] "Soft-hitting" the 1600 column limit

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [**EXTERNAL**] Re: [pgsql-admin] "Soft-hitting" the 1600 column limit
Дата
Msg-id 7370.1528328667@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: [**EXTERNAL**] Re: [pgsql-admin] "Soft-hitting" the 1600 column limit  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-admin
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Wed, Jun 6, 2018 at 4:15 PM, Ron <ronljohnsonjr@gmail.com> wrote:
>> To my mind, it makes perfect sense for columns to persist in the table
>> structure when dropped…the only question I have is whether the column would
>> survive a VACUUM FULL?  i.e. if the table is rewritten after the column is
>> dropped, would that change things?

> A cursory skim of cluster.c, plus general reasoning, leads me to think
> that the extent of the smarts of the table rewrite (for vacuum full at
> least, not cluster) is to evaluate headers for visibility and omit copying
> the physical tuples to the new heap.  The contents of each tuple are
> otherwise copied as-is (except toast pointers...).  So, yes, the variant

No; values in dropped columns get replaced by nulls during a table rewrite.
See reform_and_rewrite_tuple(), whose comments say

 * We cannot simply copy the tuple as-is, for several reasons:
 *
 * 1. We'd like to squeeze out the values of any dropped columns, both
 * to save space and to ensure we have no corner-case failures. (It's
 * possible for example that the new table hasn't got a TOAST table
 * and so is unable to store any large values of dropped cols.)
 *
 * 2. The tuple might not even be legal for the new table; this is
 * currently only known to happen as an after-effect of ALTER TABLE
 * SET WITHOUT OIDS.
 *
 * So, we must reconstruct the tuple from component Datums.

Likewise, dropped columns get replaced by nulls when an existing
tuple is updated.

So, while the dropped column never disappears from the table's structure,
over time the space it consumed goes away.

            regards, tom lane


В списке pgsql-admin по дате отправления:

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: [**EXTERNAL**] Re: [pgsql-admin] "Soft-hitting" the 1600 column limit
Следующее
От: pavan95
Дата:
Сообщение: Adding date column to system catalog "pg_database"