Performance tuning of DDL? [message #292022] |
Mon, 07 January 2008 08:20 |
lwright
Messages: 1 Registered: January 2008
|
Junior Member |
|
|
I need to add 2 columns to a table with 180M rows. I have tested this on a test server and the alter table took 9 hours to complete. The database I tested on is not in archivelog mode. Any ideas how to speed this up? My statement is
alter table tablex add
(column1 number(9,2) default 0,
column2 number(7) default 0);
|
|
|
|
Re: Performance tuning of DDL? [message #292085 is a reply to message #292022] |
Mon, 07 January 2008 14:00 |
faiz_hyd
Messages: 294 Registered: February 2006
|
Senior Member |
|
|
Hi,
I have done a similar change on PROD Database for a 100+ mill rows table,
The approach was
Quote: |
1.Modify Table Just add the column.( No default )
2.Update the table for this 2 newly added columns ( in a chuck of 500 K or depending on your Undo TS and Redolog Segement and commit the rows )
3.Modify the tables now to be with Default 0 and you can add Not Null Constraint if you want.
|
It was on 9i Release.
Thanks
[Updated on: Mon, 07 January 2008 14:02] by Moderator Report message to a moderator
|
|
|
|
|
Re: Performance tuning of DDL? [message #292140 is a reply to message #292127] |
Tue, 08 January 2008 00:31 |
rleishman
Messages: 3728 Registered: October 2005 Location: Melbourne, Australia
|
Senior Member |
|
|
I agree with Kevin. Adding a column with a non-null in every block will load every single block into the buffer cache, and will rewrite every block back to disk. It may result in chaining if you are unlucky.
A rebuild will write every block back to disk, but will bypass the buffer cache so logically is MUST be quicker in every case because it does less work. What's more, it guarantees no chaining.
The only caveat is indexing and referential integrity. If your table is riddled with indexes, foreign keys, and dependent tables, there is a possibility (a remote one) that rebuild will be slower.
Ross Leishman
|
|
|