pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Alvaro Herrera <alvherre@commandprompt.com>
Cc: Ow Mun Heng <Ow.Mun.Heng@wdc.com>
Cc: Mario Weilguni <mweilguni@sime.com>
Cc: Pgsql performance <pgsql-performance@postgresql.org>
Subject: Re: Altering a column type - Most efficient way
Date: Fri, 11 Jul 2008 10:27:34 -0400
Message-ID: <3462.1215786454@sss.pgh.pa.us> (raw)
In-Reply-To: <20080711134423.GA4110@alvh.no-ip.org>
References: <1215676380.15319.2.camel@neuromancer.home.net>
	<4875C9FA.7020101@sime.com>
	<1215682481.15319.14.camel@neuromancer.home.net>
	<20080710135756.GD3757@alvh.no-ip.org>
	<1215742620.853.10.camel@neuromancer.home.net>
	<20080711134423.GA4110@alvh.no-ip.org>

Alvaro Herrera <alvherre@commandprompt.com> writes:
> Ow Mun Heng wrote:
>> If it were this simple a change, I'm not certain why (I believe) PG is
>> checking each and every row to see if it will fit into the new column
>> definition/type. 

> Because the code that does the ALTER TYPE is very generic, and it
> doesn't (yet) have an optimization that tells it to skip the check and
> the possible table rewrite in the cases where it's obviously not needed
> (like this one).

Awhile back I looked into teaching ALTER TYPE that it needn't rewrite
if the type conversion expression parses out as just a Var with
RelabelType, but it seemed that that wouldn't cover very much of the
use-cases where a human thinks that it's "obvious" that no rewrite
is needed.  You'd really need to build in hard-wired knowledge about
the behavior of specific coercion functions, which seems entirely
unappealing.

			regards, tom lane



view thread (10+ messages)  latest in thread

Message-ID: <3462.1215786454@sss.pgh.pa.us>
Permalink:  ../3462.1215786454@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3462.1215786454@sss.pgh.pa.us

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, alvherre@commandprompt.com, Ow.Mun.Heng@wdc.com, mweilguni@sime.com
  Subject: Re: Altering a column type - Most efficient way
  In-Reply-To: <3462.1215786454@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