From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Tim Kane <tim.kane@gmail.com>
Cc: Ron <ronljohnsonjr@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Alter domain type / avoiding table rewrite
Date: Wed, 17 Apr 2019 07:23:40 -0700
Message-ID: <8f3295e8-4be9-e40a-f16d-af33eab1176c@aklaver.com> (raw)
In-Reply-To: <CADVWZZK0iyYMraqntj2+fYEaqb+dWU8p8suGU3248UEG7g3ffA@mail.gmail.com>
References: <CADVWZZKjhV9fLpewPdQMZx7V6kvGJViwMEDrPAv9m50rGeK9UA@mail.gmail.com>
<26216.1555423922@sss.pgh.pa.us>
<9dc52f4b-94b5-813c-52ba-be22dec1cb93@aklaver.com>
<27283.1555425748@sss.pgh.pa.us>
<c2a2f6f0-9e85-3c43-54d5-b68c592695ed@gmail.com>
<CADVWZZ+E2GUPnj8_JoPkh05d9t31HqBs4SfSVHY8YWPJfKZ=Ug@mail.gmail.com>
<2f57aafd-f034-0f82-5739-614607e4ba0e@aklaver.com>
<CADVWZZK0iyYMraqntj2+fYEaqb+dWU8p8suGU3248UEG7g3ffA@mail.gmail.com>
On 4/17/19 2:14 AM, Tim Kane wrote:
>
>
> On Tue, 16 Apr 2019 at 18:04, Adrian Klaver <adrian.klaver@aklaver.com
> <mailto:adrian.klaver@aklaver.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.____
The table definition and the size of the data set would help with
interpreting the below.
>
> __
>
> __
>
> PSQL:alpha_db/postgres@[local]=# select relfilenode from pg_class where
> relname='test';____
>
> relfilenode____
>
> -------------____
>
> 20669469 <tel:20669469>____
>
> (1 row)____
>
> __ __
>
> PSQL:alpha_db/postgres@[local]=# alter table test alter COLUMN exec_id
> set data type varchar(9);____
>
> ALTER TABLE____
>
> Time: 6605.454 ms____
>
>
> PSQL:alpha_db/postgres@[local]=# select relfilenode from pg_class where
> relname='test';____
>
> relfilenode____
>
> -------------____
>
> 20671802 <tel: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@[local]=# alter table test alter COLUMN exec_id
> set data type execid_t;____
>
> ALTER TABLE____
>
> Time: 1.360 ms____
>
> PSQL:alpha_db/postgres@[local]=# select relfilenode from pg_class where
> relname='test';____
>
> relfilenode____
>
> -------------____
>
> 20671802 <tel:20671802>____
>
> (1 row)____
>
> __ __
>
> Time: 0.331 ms____
>
> __
>
>
> Apologies if this formats badly :-/ transcribing between devices not
> well suited to email.
>
> Tim
>
--
Adrian Klaver
adrian.klaver@aklaver.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: adrian.klaver@aklaver.com, tim.kane@gmail.com, ronljohnsonjr@gmail.com
Subject: Re: Alter domain type / avoiding table rewrite
In-Reply-To: <8f3295e8-4be9-e40a-f16d-af33eab1176c@aklaver.com>
References: <CADVWZZKjhV9fLpewPdQMZx7V6kvGJViwMEDrPAv9m50rGeK9UA@mail.gmail.com> <26216.1555423922@sss.pgh.pa.us> <9dc52f4b-94b5-813c-52ba-be22dec1cb93@aklaver.com> <27283.1555425748@sss.pgh.pa.us> <c2a2f6f0-9e85-3c43-54d5-b68c592695ed@gmail.com> <CADVWZZ+E2GUPnj8_JoPkh05d9t31HqBs4SfSVHY8YWPJfKZ=Ug@mail.gmail.com> <2f57aafd-f034-0f82-5739-614607e4ba0e@aklaver.com> <CADVWZZK0iyYMraqntj2+fYEaqb+dWU8p8suGU3248UEG7g3ffA@mail.gmail.com> <8f3295e8-4be9-e40a-f16d-af33eab1176c@aklaver.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox