Site sponsored by: Idera The gold standard of SQL Server performance monitoring & diagnostics.
SQL Server Performance

  • Home
  • Articles
  • Forums
  • Tips
  • Quiz
  • FAQ's
  • Blogs
  • Software
  • Books
  • About Us
RSS Feeds
Sign in | Join


Article Topics

All Articles
Performance Tuning
Audit
Business Intelligence
Clustering
Reporting Services
Developer
General DBA
ASP.NET / ADO.NET

Write for Us

Share your SQL Server knowledge with others and raise your profile in the community More...
Latest Articles

System Data Collection Reports
Recover Data Using Database Snapshots
Analyze and Fix Index Fragmentation in SQL Server 2008
Powerful Geographical Visualisations made easy with SQL 2008 Spatial (Part 2) ...

More     
 
Latest FAQ's

How to alter a User Defined Data Type?
How to unzip a File in SSIS?
How to view previous query plans?
ALTER TABLE SWITCH statement failed because the object '%.*ls' is not ...

More     
   
Latest Software Reviews

Spotlight on ApexSQL Doc 2008
ApexSQL Enforce
Embarcadero Change Manager
SQL Server DBA Dashboard

More     

articles >> performance tuning >> How SQL Server Determines an Execution Plan ...

How SQL Server Determines an Execution Plan Using Available Indexes and Statistics

By : Nils Bevaart
May 17, 2005

Page 4 / 4

Because SQL Server expects 144 rows, the effort of filtering the records for the second parameter is predicted to be faster than to use two indexes and cross referencing these. However, the actual row count is much higher, causing this plan to be far from ideal.

Even though the number of occurrences for 'Smits' is approximately half of the number for 'Smit', this query takes three and a half minutes to execute while the query for Smit only takes about 1 second.

Work Around

So how do you solve this problem? Statistics can not be expanded. They are designed to be kept small, so that the process of determining an execution plan is kept small. Even if the statistics could be doubled in size, this problem will still arise.

The option of using an index hint will only be helpful if used in all the queries with a search parameter in this field. Adding an index hint is a manual job, requiring knowledge of the dataset. A human will encounter the same difficulties in determining a best use of indexes as SQL Server itself. Also, automating the use of index hints in a production environment is time-consuming and far from efficient.

In these situations, a work around is the best option. By changing the specific index into a clustered index, a bookmark lookup is no longer necessary. This saves considerable time and effort. If the statistics are off and the number of hits exceeds the expected number, all relevant records are clustered together and require little extra time.

In the above examples, if the index on gnaam is a clustered index, the execution plan is as follows:

Figure 6: Execution Plan - Search for Smits and Kerkstraat with Clustered Index

This query takes 7 seconds to execute. A significant improvement.

Index Planning

The effect of changing currently existing clustered index into a non-clustered index should be examined. There can only be one clustered index on a table. In general, the difference in performance for a field containing unique values is minimal between a clustered and a non-clustered index. If, however, this field is used in a one to many relationships, the general performance for the overall queries to the database might decline.

It is wise to take all these aspects into consideration when designing the index structure for your databases. It is often worth the effort to try different configurations and go with the one best suitable. Of course using the Index Tuning Wizard will help in this process.

Nils Bevaart has been a DBA for 5 years. He works for a Dutch government agency specializing in civilian registration. He has experience with SQL Server 2000 administration, performance tuning, and security. He is married and has a daughter.

Copyright 2005 by the author.


<< Prev Page         








Home | Peformance Articles | Audit Articles | Business Intelligence Articles | Clustering Articles | Developer Articles | Reporting Services Articles | DBA Articles | ASP.NET / ADO.NET Articles | DBA FAQ's | Developer Peformance FAQ's | DBA Peformance FAQ's | Developer FAQ's | Clustering FAQ's | Error Messages | Audit Tool Reviews | Backup Tool Reviews | Coding Tool Reviews | Compare Tool Reviews | Documentation Tool Reviews | Design Tool Reviews | Monitoring Tool Reviews | Log Tool Reviews | Reporting Tool Reviews | Clustering Tool Reviews | Security Tool Reviews | Change Management Tool Reviews | Remote Access Tool Reviews | Book Reviews | Security Tool Reviews | QDPMA Performance Tuning | ADO.NET / ASP.NET | Administration | Analysis/OLAP Services | Application Development | Configuration | Components | ETL | Hardware | High Availability | Hints | Index | Misc | Operating Systems | Performance Tuning | Replication | T-SQL | Views


              © 1999-2008 by T10 Media. All rights reserved