Re: How to do faster DML

From: veem v <veema0000(at)gmail(dot)com>
To: Ron Johnson <ronljohnsonjr(at)gmail(dot)com>, "Peter J(dot) Holzer" <hjp-pgsql(at)hjp(dot)at>, Greg Sabino Mullane <htamfids(at)gmail(dot)com>, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
Cc: "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: How to do faster DML
Date: 2024-02-14 18:11:15
Message-ID: CAB+=1TV2i5rvO-dVhj+8NObgp8LTwBBNvi4VX5odh5onKNa7UQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, 14 Feb, 2024, 10:30 am Ron Johnson, <ronljohnsonjr(at)gmail(dot)com> wrote:

> On Tue, Feb 13, 2024 at 4:17 PM veem v <veema0000(at)gmail(dot)com> wrote:
> [sni[]
>
>> One question here, if we have defined one column as a fixed length data
>> type "integer" and slowly we noticed the length of data keeps increasing
>> (in case of a sequence generated PK column which will keep increasing), and
>> we want to alter the column to "bigint" now. In such scenario, will it
>> append/pad the additional spaces to all the existing values which were
>> already stored with integer type initially in the table. And that would be
>> then an increase to the existing table storage. Please correct me if I'm
>> wrong.
>>
>
> ALTER TABLE foo ALTER COLUMN bar BIGINT; rewrites the whole table. Do
> yourself a favor, and start with BIGINT.
>

Not yet tried, but that's interesting. I was initially thinking as it will
be increasing the length, so it would be just a metadata change and finish
within seconds.

But as you mentioned, it seems to be the effect of "fixed length data
type" which is why it's going to rewrite whole table even we just increases
the column length. Hope it won't be the case in variable length data type.

>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Yongye Serkfem 2024-02-14 18:38:54 PITR
Previous Message Ayush Vatsa 2024-02-14 17:00:46 Re: Query regarding function cleanup in extension upgrade path