Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 ALTER TABLE time

Author  Topic 

aiken
Aged Yak Warrior

525 Posts

Posted - 2002-12-30 : 19:54:58
...I've noticed that sometimes doing an alter table to add a new column is almost instantaneous, even on large tables, and sometimes it's painfully slow and locks the table for ages (especailly on large tables).

Assuming my perceptions are correct, my hypothesis is that SQL server rounds row size up to some even? power of 2? prime? number, so sometimes each row has the empty space already available, and in that case alter talbe is quick. If rows have to be expanded, it takes longer and can cause page splits, etc.

It's a nice theory. Can anyone tell me if it's true, or if I've just been at the eggnog too much recently?

If it *is* true, is there any way to determine what free space a row has so I can decide if I need to make a change during a big maintenance window?

Thanks
-b

aiken
Aged Yak Warrior

525 Posts

Posted - 2002-12-30 : 20:00:35
One more thing to add -- I'm looking to add an int field to a table with many rows. I've got a varchar I could shorten to "make room," if that would help, and a uniqueidentifier I need to do away with altogether.

Cheers
-b

Go to Top of Page
   

- Advertisement -