Re: Alter domain type / avoiding table rewrite

From: Tim Kane <tim(dot)kane(at)gmail(dot)com>
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Cc: Ron <ronljohnsonjr(at)gmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Alter domain type / avoiding table rewrite
Date: 2019-04-17 09:14:51
Message-ID: CADVWZZK0iyYMraqntj2+fYEaqb+dWU8p8suGU3248UEG7g3ffA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 16 Apr 2019 at 18:04, Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
wrote:

>
>
> Where are you seeing the rewrite in your case?

I’m unfamiliar with ctid (which I now plan to read up on)… I’ve been
looking at *relfilenode*

I’ve observed that relfilenode changes when altering from *old_type *
*à varchar(9) *and the operation takes 6 seconds on this data set.

PSQL:alpha_db/postgres(at)[local]=# select relfilenode from pg_class where
relname='test';

relfilenode

-------------

20669469

(1 row)

PSQL:alpha_db/postgres(at)[local]=# alter table test alter COLUMN exec_id set
data type varchar(9);

ALTER TABLE

Time: 6605.454 ms

PSQL:alpha_db/postgres(at)[local]=# select relfilenode from pg_class where
relname='test';

relfilenode

-------------

20671802

(1 row)

And then the other way… from *varchar(9) **à old_type*

refilenode does not change, and the operation takes 0.3ms

PSQL:alpha_db/postgres(at)[local]=# alter table test alter COLUMN exec_id set
data type execid_t;

ALTER TABLE

Time: 1.360 ms

PSQL:alpha_db/postgres(at)[local]=# select relfilenode from pg_class where
relname='test';

relfilenode

-------------

20671802

(1 row)

Time: 0.331 ms

Apologies if this formats badly :-/ transcribing between devices not well
suited to email.

Tim

>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Prakash Ramakrishnan 2019-04-17 11:08:23 upgrade issue 10 to 11
Previous Message Zahir Lalani 2019-04-17 07:42:55 RE: Possible corrupt index?