SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Creating an index


Creating an index

Author
Message
meichner
meichner
SSC-Addicted
SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)

Group: General Forum Members
Points: 493 Visits: 640
I am not really a DBA, but I have assumed the role because of cutbacks. I need to add an index to a few of my tables due to performance issues. I have a few questions that I would appreciate answers to.

1. Can I add an index to a table while the table is being accessed by users?

2. Is there any downside to adding an index to a table?

3. Is there any downside to adding the index while the table is being accessed? In other words will there be locking issues or something else that I have to be aware of?

4. Will I need to re test the application that reads and writes to the database after adding the index or will the addition of the new index be transparent to the users (with the exception of the reads being faster)?

Thanks so much
SQLRNNR
SQLRNNR
SSC-Dedicated
SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)

Group: General Forum Members
Points: 33764 Visits: 18560
meichner (8/28/2009)
I am not really a DBA, but I have assumed the role because of cutbacks. I need to add an index to a few of my tables due to performance issues. I have a few questions that I would appreciate answers to.

1. Can I add an index to a table while the table is being accessed by users?

2. Is there any downside to adding an index to a table?

3. Is there any downside to adding the index while the table is being accessed? In other words will there be locking issues or something else that I have to be aware of?

4. Will I need to re test the application that reads and writes to the database after adding the index or will the addition of the new index be transparent to the users (with the exception of the reads being faster)?

Thanks so much




What Version of SQL?
1. Depends - table and index. It would be best to do it during maintenance in many cases.
3. There is downside to adding an index while the table is being accessed - locking may occur. Depending on the nature of the table and the index being created, you could render the app inaccessible during the index creation.
2. Downside to adding the index will be seen in inserts and updates. But this needs to be weighed against how often the table is accessed just for selects/ reads.
4. Depends - sometimes it may be transparent, sometimes it could require retesting the app.



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw

meichner
meichner
SSC-Addicted
SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)

Group: General Forum Members
Points: 493 Visits: 640
CirquedeSQLeil (8/28/2009)
meichner (8/28/2009)
I am not really a DBA, but I have assumed the role because of cutbacks. I need to add an index to a few of my tables due to performance issues. I have a few questions that I would appreciate answers to.

1. Can I add an index to a table while the table is being accessed by users?

2. Is there any downside to adding an index to a table?

3. Is there any downside to adding the index while the table is being accessed? In other words will there be locking issues or something else that I have to be aware of?

4. Will I need to re test the application that reads and writes to the database after adding the index or will the addition of the new index be transparent to the users (with the exception of the reads being faster)?

Thanks so much




What Version of SQL?
1. Depends - table and index. It would be best to do it during maintenance in many cases.
3. There is downside to adding an index while the table is being accessed - locking may occur. Depending on the nature of the table and the index being created, you could render the app inaccessible during the index creation.
2. Downside to adding the index will be seen in inserts and updates. But this needs to be weighed against how often the table is accessed just for selects/ reads.
4. Depends - sometimes it may be transparent, sometimes it could require retesting the app.


I am using sql server 2005. Does that make any difference to the answers you supplied?

Thanks
Clive Strong
Clive Strong
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1556 Visits: 6595
What Version of SQL?
1. Depends - table and index. It would be best to do it during maintenance in many cases.
3. There is downside to adding an index while the table is being accessed - locking may occur. Depending on the nature of the table and the index being created, you could render the app inaccessible during the index creation.
2. Downside to adding the index will be seen in inserts and updates. But this needs to be weighed against how often the table is accessed just for selects/ reads.
4. Depends - sometimes it may be transparent, sometimes it could require retesting the app.

I am using sql server 2005. Does that make any difference to the answers you supplied?

Thanks


The same logic will apply for all versions of SQL Server. Personally, I'd not add the indexes to production while users are using the database.

Do you have access to a development or test server? It would be far better to test and analyze your index changes there - if you can look at the execution plans, IO stats and general resource usage before and after the new index, then you'll be able to deploy to the production environment safer in the knowledge that your new index is beneficial to the users.

Good luck!
meichner
meichner
SSC-Addicted
SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)

Group: General Forum Members
Points: 493 Visits: 640
Clive Strong (8/29/2009)
What Version of SQL?
1. Depends - table and index. It would be best to do it during maintenance in many cases.
3. There is downside to adding an index while the table is being accessed - locking may occur. Depending on the nature of the table and the index being created, you could render the app inaccessible during the index creation.
2. Downside to adding the index will be seen in inserts and updates. But this needs to be weighed against how often the table is accessed just for selects/ reads.
4. Depends - sometimes it may be transparent, sometimes it could require retesting the app.

I am using sql server 2005. Does that make any difference to the answers you supplied?

Thanks


The same logic will apply for all versions of SQL Server. Personally, I'd not add the indexes to production while users are using the database.

Do you have access to a development or test server? It would be far better to test and analyze your index changes there - if you can look at the execution plans, IO stats and general resource usage before and after the new index, then you'll be able to deploy to the production environment safer in the knowledge that your new index is beneficial to the users.

Good luck!


Thanks so much for the advice. I do have a development environment. The problem is that I have a great deal of data in the production and very little in development. Due to ongoing development I can't restore the production data to development. I am going to have to come up with a way to restore the data from selected production tables to development. Once done I will follow your advice and add the indexes to my development database and test before creating the indexes in production. I will then have to add in the index when the application is not being used.

Thanks again
SQLRNNR
SQLRNNR
SSC-Dedicated
SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)SSC-Dedicated (33K reputation)

Group: General Forum Members
Points: 33764 Visits: 18560
Clive Strong (8/29/2009)
What Version of SQL?
1. Depends - table and index. It would be best to do it during maintenance in many cases.
3. There is downside to adding an index while the table is being accessed - locking may occur. Depending on the nature of the table and the index being created, you could render the app inaccessible during the index creation.
2. Downside to adding the index will be seen in inserts and updates. But this needs to be weighed against how often the table is accessed just for selects/ reads.
4. Depends - sometimes it may be transparent, sometimes it could require retesting the app.

I am using sql server 2005. Does that make any difference to the answers you supplied?

Thanks


The same logic will apply for all versions of SQL Server. Personally, I'd not add the indexes to production while users are using the database.

Do you have access to a development or test server? It would be far better to test and analyze your index changes there - if you can look at the execution plans, IO stats and general resource usage before and after the new index, then you'll be able to deploy to the production environment safer in the knowledge that your new index is beneficial to the users.

Good luck!


The same logic changes somewhat when going from SQL 2000 or 2005 standard to 2005 Enterprise, where one can use the online option. By using the online option, you may see less impact when creating the index.

http://msdn.microsoft.com/en-us/library/ms188783(SQL.90).aspx]



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw

Clive Strong
Clive Strong
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1556 Visits: 6595
Very true...If only my company would let me get my hands on EE!!

As for moving data from certain tables from production to development, you can use SSIS/DTS, BCP, backup and restore (if you placed files in specific file groups) or direct copy (even a subset of data would help).
meichner
meichner
SSC-Addicted
SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)

Group: General Forum Members
Points: 493 Visits: 640
Clive Strong (9/1/2009)
Very true...If only my company would let me get my hands on EE!!

As for moving data from certain tables from production to development, you can use SSIS/DTS, BCP, backup and restore (if you placed files in specific file groups) or direct copy (even a subset of data would help).


Thanks so much for the advice. I will attempt to learn how to use the options you suggested (SSIS/DTS, BCP). Can any of these be used on the live database?

Thanks
Clive Strong
Clive Strong
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1556 Visits: 6595
meichner (9/2/2009)
Clive Strong (9/1/2009)
Very true...If only my company would let me get my hands on EE!!

As for moving data from certain tables from production to development, you can use SSIS/DTS, BCP, backup and restore (if you placed files in specific file groups) or direct copy (even a subset of data would help).


Thanks so much for the advice. I will attempt to learn how to use the options you suggested (SSIS/DTS, BCP). Can any of these be used on the live database?

Thanks


You can, yes...But it's better to do this offline.
meichner
meichner
SSC-Addicted
SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)

Group: General Forum Members
Points: 493 Visits: 640
Clive Strong (9/2/2009)
meichner (9/2/2009)
Clive Strong (9/1/2009)
Very true...If only my company would let me get my hands on EE!!

As for moving data from certain tables from production to development, you can use SSIS/DTS, BCP, backup and restore (if you placed files in specific file groups) or direct copy (even a subset of data would help).


Thanks so much for the advice. I will attempt to learn how to use the options you suggested (SSIS/DTS, BCP). Can any of these be used on the live database?

Thanks


You can, yes...But it's better to do this offline.


Thanks so much for all the help.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search