From: Tom Lane <tgl@sss.pgh.pa.us>
To: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: Jeremy Finzel <finzelj@gmail.com>
Cc: Postgres General <pgsql-general@postgresql.org>
Subject: Re: Cases where alter table set type varchar(longer length) still needs table rewrite
Date: Mon, 17 Feb 2020 13:19:52 -0500
Message-ID: <9756.1581963592@sss.pgh.pa.us> (raw)
In-Reply-To: <45da6f97-119a-fc3f-9393-4d056bddb3f5@aklaver.com>
References: <CAMa1XUiqdpJZHq_bDAsvbEZw=RjtOuH3z1xz-Xd27a6b1Pf9xA@mail.gmail.com>
<573.1581949272@sss.pgh.pa.us>
<CAMa1XUgLD7kr55ZmwdgtvY9e26WMv4MA5H7aDfG1_Ar7TRGw6Q@mail.gmail.com>
<45da6f97-119a-fc3f-9393-4d056bddb3f5@aklaver.com>
Adrian Klaver <adrian.klaver@aklaver.com> writes:
> On 2/17/20 7:01 AM, Jeremy Finzel wrote:
>> I'm still not sure why a rebuild of this index would be required,
>> technically speaking. But perhaps in any case the docs should have
>> something to the effect that expression indexes may require rebuild
>> under specific circumstances?
> [ it is already ]
Yeah. In principle, we wouldn't need to rebuild the indexes in this
case, since there's no semantic difference between a value sourced
from a varchar(N) column and a varchar(some-other-N) column. In general,
though, ALTER COLUMN TYPE doesn't know whether that's true; and there
are definitely binary-compatible cases where it *does* matter.
(An example is that coercing integer to OID is allowed without a
table rewrite, but an index rebuild is needed because the sort
order is different.) So right now, any index mentioning the altered
column has to be rebuilt.
Maybe someday we'll figure out how to do better. I'm kind of wondering
whether it wouldn't be safe to assume that changes that only change the
typmod and not the type OID don't require index rebuilds.
regards, tom lane
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: tgl@sss.pgh.pa.us, adrian.klaver@aklaver.com, finzelj@gmail.com
Subject: Re: Cases where alter table set type varchar(longer length) still needs table rewrite
In-Reply-To: <9756.1581963592@sss.pgh.pa.us>
References: <CAMa1XUiqdpJZHq_bDAsvbEZw=RjtOuH3z1xz-Xd27a6b1Pf9xA@mail.gmail.com> <573.1581949272@sss.pgh.pa.us> <CAMa1XUgLD7kr55ZmwdgtvY9e26WMv4MA5H7aDfG1_Ar7TRGw6Q@mail.gmail.com> <45da6f97-119a-fc3f-9393-4d056bddb3f5@aklaver.com> <9756.1581963592@sss.pgh.pa.us>
* 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