Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

Creating an index Expand / Collapse
Author
Message
Posted Friday, August 28, 2009 7:13 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, February 6, 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


Post #779358
Posted Friday, August 28, 2009 10:05 PM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Today @ 1:53 AM
Points: 17,812, Visits: 15,738
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
Post #779368
Posted Saturday, August 29, 2009 8:09 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, February 6, 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
Post #779417
Posted Saturday, August 29, 2009 10:09 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Yesterday @ 9:22 AM
Points: 1,116, Visits: 6,462
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!
Post #779439
Posted Saturday, August 29, 2009 11:52 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, February 6, 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
Post #779457
Posted Monday, August 31, 2009 10:04 AM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Today @ 1:53 AM
Points: 17,812, Visits: 15,738
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
Post #780015
Posted Tuesday, September 1, 2009 1:54 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Yesterday @ 9:22 AM
Points: 1,116, Visits: 6,462
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).
Post #780488
Posted Wednesday, September 2, 2009 5:53 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, February 6, 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
Post #781344
Posted Wednesday, September 2, 2009 6:47 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Yesterday @ 9:22 AM
Points: 1,116, Visits: 6,462
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.
Post #781388
Posted Thursday, September 3, 2009 6:46 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, February 6, 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.
Post #782114
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse