pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #7502:  ALTER COLUMN TYPE processed  even if column type matches
3+ messages / 3 participants
[nested] [flat]

* BUG #7502:  ALTER COLUMN TYPE processed  even if column type matches
@ 2012-08-23 14:37  tigran.mkrtchyan@desy.de
  0 siblings, 1 reply; 3+ messages in thread

From: tigran.mkrtchyan@desy.de @ 2012-08-23 14:37 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      7502
Logged by:          Tigran Mkrtchyan
Email address:      tigran.mkrtchyan@desy.de
PostgreSQL version: 9.1.1
Operating system:   Linux
Description:        

Hi,

we have notice that 

ALTER TABLE a_table ALTER COLUMN a_column TYPE varchar(36)

will be processed by postgres even if column types matches to the new one.
Technically, this is not an issue, except on big tables ( ~ 30M entries )
takes some time.

Tigran.





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #7502: ALTER COLUMN TYPE processed even if column type matches
@ 2012-08-23 15:43  Alvaro Herrera <alvherre@2ndquadrant.com>
  parent: tigran.mkrtchyan@desy.de
  0 siblings, 1 reply; 3+ messages in thread

From: Alvaro Herrera @ 2012-08-23 15:43 UTC (permalink / raw)
  To: tigran.mkrtchyan <tigran.mkrtchyan@desy.de>; +Cc: pgsql-bugs

Excerpts from tigran.mkrtchyan's message of jue ago 23 10:37:02 -0400 2012:
> The following bug has been logged on the website:
> 
> Bug reference:      7502
> Logged by:          Tigran Mkrtchyan
> Email address:      tigran.mkrtchyan@desy.de
> PostgreSQL version: 9.1.1
> Operating system:   Linux
> Description:        
> 
> Hi,
> 
> we have notice that 
> 
> ALTER TABLE a_table ALTER COLUMN a_column TYPE varchar(36)
> 
> will be processed by postgres even if column types matches to the new one.
> Technically, this is not an issue, except on big tables ( ~ 30M entries )
> takes some time.

This is a feature, at least for versions predating the rewrite of VACUUM
FULL.  The reason is that this is the only cheap way to cause the table
to be rewritten without causing it to be reordered (what CLUSTER does).
See http://wiki.postgresql.org/wiki/VACUUM_FULL

So the ALTER TABLE trick is not needed in 9.0, but is useful in previous
releases.  There are optimizations to avoid the table rewrite in certain
cases in 9.2:
http://wiki.postgresql.org/wiki/What's_new_in_PostgreSQL_9.2#Reduce_ALTER_TABLE_rewrites

According to that page, though, a change of varchar(36) to varchar(36)
would still require a table rewrite, which doesn't make sense to me.  Is
the wiki page inaccurate maybe?

-- 
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #7502: ALTER COLUMN TYPE processed even if column type matches
@ 2012-08-23 17:55  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Alvaro Herrera <alvherre@2ndquadrant.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Tom Lane @ 2012-08-23 17:55 UTC (permalink / raw)
  To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: tigran.mkrtchyan <tigran.mkrtchyan@desy.de>; pgsql-bugs

Alvaro Herrera <alvherre@2ndquadrant.com> writes:
> So the ALTER TABLE trick is not needed in 9.0, but is useful in previous
> releases.  There are optimizations to avoid the table rewrite in certain
> cases in 9.2:
> http://wiki.postgresql.org/wiki/What's_new_in_PostgreSQL_9.2#Reduce_ALTER_TABLE_rewrites

> According to that page, though, a change of varchar(36) to varchar(36)
> would still require a table rewrite, which doesn't make sense to me.  Is
> the wiki page inaccurate maybe?

Yeah - you can easily convince yourself by timing it that no rewrite
happens in 9.2.

			regards, tom lane




^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2012-08-23 17:55 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2012-08-23 14:37 BUG #7502:  ALTER COLUMN TYPE processed  even if column type matches tigran.mkrtchyan@desy.de
2012-08-23 15:43 ` Re: BUG #7502: ALTER COLUMN TYPE processed even if column type matches Alvaro Herrera <alvherre@2ndquadrant.com>
2012-08-23 17:55   ` Re: BUG #7502: ALTER COLUMN TYPE processed even if column type matches Tom Lane <tgl@sss.pgh.pa.us>

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