Обсуждение: how to clean dropped column in pg_attribute

Поиск
Список
Период
Сортировка

how to clean dropped column in pg_attribute

От
ZongtianHou
Дата:
Hi, everyone

I found dropped columns still exist in pg_attribute table. In the below example I drop c2 column and vacuum (full) this
tableand pg_attribute, it still exist (the last row). how can I clean it away?  

postgres=# select * from pg_attribute where attrelid=16515;
 attrelid |           attname            | atttypid | attstattarget | attlen | attnum | attndims | attcacheoff |
atttypmod| attbyval | attstorage | attalign | attnotnull | atthasdef | attisdropped | attislocal | attinhcount 

----------+------------------------------+----------+---------------+--------+--------+----------+-------------+-----------+----------+------------+----------+------------+-----------+--------------+------------+-------------
    16515 | c1                           |       23 |            -1 |      4 |      1 |        0 |          -1 |
-1| t        | p          | i        | f          | f         | f            | t          |           0 
    16515 | c3                           |       23 |            -1 |      4 |      3 |        0 |          -1 |
-1| t        | p          | i        | f          | f         | f            | t          |           0 
    16515 | ctid                         |       27 |             0 |      6 |     -1 |        0 |          -1 |
-1| f        | p          | s        | t          | f         | f            | t          |           0 
    16515 | xmin                         |       28 |             0 |      4 |     -3 |        0 |          -1 |
-1| t        | p          | i        | t          | f         | f            | t          |           0 
    16515 | cmin                         |       29 |             0 |      4 |     -4 |        0 |          -1 |
-1| t        | p          | i        | t          | f         | f            | t          |           0 
    16515 | xmax                         |       28 |             0 |      4 |     -5 |        0 |          -1 |
-1| t        | p          | i        | t          | f         | f            | t          |           0 
    16515 | cmax                         |       29 |             0 |      4 |     -6 |        0 |          -1 |
-1| t        | p          | i        | t          | f         | f            | t          |           0 
    16515 | tableoid                     |       26 |             0 |      4 |     -7 |        0 |          -1 |
-1| t        | p          | i        | t          | f         | f            | t          |           0 
    16515 | gp_segment_id                |       23 |             0 |      4 |     -8 |        0 |          -1 |
-1| t        | p          | i        | t          | f         | f            | t          |           0 
    16515 | c4                           |       16 |            -1 |      1 |      4 |        0 |          -1 |
-1| t        | p          | c        | f          | f         | f            | t          |           0 
    16515 | ........pg.dropped.2........ |        0 |             0 |      4 |      2 |        0 |          -1 |
-1| t        | p          | i        | f          | f         | t            | t          |           0 
(11 rows)


Re: how to clean dropped column in pg_attribute

От
hubert depesz lubaczewski
Дата:
On Tue, Sep 08, 2020 at 05:38:24PM +0800, ZongtianHou wrote:
> I found dropped columns still exist in pg_attribute table. In the
> below example I drop c2 column and vacuum (full) this table and
> pg_attribute, it still exist (the last row). how can I clean it away? 

Unfortunately only by copying the table aside, and then renaming new
table.

But - the dropped attribute will not sure any disk space, as long as you
ran some vacuums.

Best regards,

depesz




Re: how to clean dropped column in pg_attribute

От
ZongtianHou
Дата:
Ok, thanks for this info

Best regards,
Zongtian

> On Sep 8, 2020, at 5:49 PM, hubert depesz lubaczewski <depesz@depesz.com> wrote:
>
> On Tue, Sep 08, 2020 at 05:38:24PM +0800, ZongtianHou wrote:
>> I found dropped columns still exist in pg_attribute table. In the
>> below example I drop c2 column and vacuum (full) this table and
>> pg_attribute, it still exist (the last row). how can I clean it away?
>
> Unfortunately only by copying the table aside, and then renaming new
> table.
>
> But - the dropped attribute will not sure any disk space, as long as you
> ran some vacuums.
>
> Best regards,
>
> depesz
>