|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Monday, February 06, 2012 12:43 PM
Points: 215,
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
|
|
|
|
|
SSCoach
         
Group: General Forum Members
Last Login: Today @ 5:03 PM
Points: 18,853,
Visits: 12,438
|
|
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 2008
SQL RNNR
Posting Performance Based Questions - Gail Shaw Posting Data Etiquette - Jeff Moden Hidden RBAR - Jeff Moden VLFs and the Tran Log - Kimberly Tripp
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Monday, February 06, 2012 12:43 PM
Points: 215,
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
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Monday, May 13, 2013 10:12 AM
Points: 959,
Visits: 6,341
|
|
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!
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Monday, February 06, 2012 12:43 PM
Points: 215,
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
|
|
|
|
|
SSCoach
         
Group: General Forum Members
Last Login: Today @ 5:03 PM
Points: 18,853,
Visits: 12,438
|
|
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 2008
SQL RNNR
Posting Performance Based Questions - Gail Shaw Posting Data Etiquette - Jeff Moden Hidden RBAR - Jeff Moden VLFs and the Tran Log - Kimberly Tripp
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Monday, May 13, 2013 10:12 AM
Points: 959,
Visits: 6,341
|
|
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).
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Monday, February 06, 2012 12:43 PM
Points: 215,
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
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Monday, May 13, 2013 10:12 AM
Points: 959,
Visits: 6,341
|
|
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.
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Monday, February 06, 2012 12:43 PM
Points: 215,
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.
|
|
|
|