pgsql: Teach ALTER TABLE .. SET DATA TYPE to avoid some table rewrites.

From: Robert Haas <rhaas(at)postgresql(dot)org>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Teach ALTER TABLE .. SET DATA TYPE to avoid some table rewrites.
Date: 2011-02-12 13:43:42
Message-ID: E1PoFlG-0005Et-J1@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox
Thread:
Lists: pgsql-committers

Teach ALTER TABLE .. SET DATA TYPE to avoid some table rewrites.

When the old type is binary coercible to the new type and the using
clause does not change the column contents, we can avoid a full table
rewrite, though any indexes on the affected columns will still need
to be rebuilt. This applies, for example, when changing a varchar
column to be of type text.

The prior coding assumed that the set of operations that force a
rewrite is identical to the set of operations that must be propagated
to tables making use of the affected table's rowtype. This is
no longer true: even though the tuples in those tables wouldn't
need to be modified, the data type change invalidate indexes built
using those composite type columns. Indexes on the table we're
actually modifying can be invalidated too, of course, but the
existing machinery is sufficient to handle that case.

Along the way, add some debugging messages that make it possible
to understand what operations ALTER TABLE is actually performing
in these cases.

Noah Misch and Robert Haas

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/d31e2a495b6f2127afc31b4da2e5f4e89aa2cdfe

Modified Files
--------------
doc/src/sgml/ref/alter_table.sgml | 16 ++++---
src/backend/catalog/index.c | 5 ++
src/backend/commands/tablecmds.c | 90 ++++++++++++++++++++++++++++---------
3 files changed, 83 insertions(+), 28 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2011-02-12 13:58:41 pgsql: DDL support for collations
Previous Message Alex Hunsaker 2011-02-12 09:18:36 Re: [COMMITTERS] pgsql: Force strings passed to and from plperl to be in UTF8 encoding.