Reputation: 17764
I understand that this question isn't one in that I'm going to get a precise answer. I'm going for ball park figures.
I basically need a way to answer this question: When I add this column or index, is it going to lock the table for 1 minute, 10 minutes or and hour+. The reason being we need to know if this is implementation is going to require us to notify clients of a break in service or if we can do it at off peak hours.
I realize there are a lot of factors involved in a question like this but, I'd like to focus in on the ones that aren't obvious such as machine performance, current system load etc.
Ideally a formal of some sort like:
(Number of Rows) * (0.01 Secs) * (Some unknown factors) = 112.secs
Also is there a substantial difference between adding an index an a column? What about different types of columns that are added?
To put the question another way, what are the largest factors in determining if an alter statement will be slow or very slow?
Upvotes: 2
Views: 204
Reputation: 171491
The best approach here is to have a staging copy of your database on similar hardware with the same data set, ideally generated from nightly backups.
Then you can try your schema modifications out without fear, and get a good rough idea of how long it should take. Of course a database under load will take longer than one that is not. To factor this in, you could run some load-testing scripts against the staging database that run common application operations while trying out your schema changes.
Upvotes: 3