FREE BOOK

Chapter 1: SQL Query Performance Tuning

Posted by Apress Free Book | SQL Server 2005/2008 January 26, 2010
Query performance tuning is an important part of today's database applications. Often you can achieve large savings in both time and money with proper query performance tuning

Performance Baseline

One of the main objectives of performance analysis is to understand the underlying level of system use or pressure on different hardware and software subsystems. This knowledge helps you in the following ways:

  • Allows you to analyze resource bottlenecks.
  • Enables you to troubleshoot by comparing system utilization patterns with a preestablished baseline.
  • Assists you in making accurate estimates in capacity planning and scheduling hardware upgrades.
  • Aids you in identifying low-utilization periods when the database administrative activities can be executed.
  • Helps you estimate the nature of possible hardware downsizing or server consolidation. Why would a company downsize? Well, in the past, some companies leased very high-end systems expecting strong growth, but because of poor growth, they are now forced to downsize their system setups. And consolidation? Companies may sometimes buy too many servers or realize that the maintenance and licensing costs are too high. This would make using fewer servers very attractive.

Therefore, to better understand your application's resource requirements, you should create a baseline for your application's hardware and software usage. A baseline serves as a statistic of your system's current usage pattern and as a reference with which to compare future statistics. Baseline analysis helps you understand your application's behavior during a stable period, how hardware resources are used during such periods, and what the software characteristics are. With a baseline in place, you can do the following:

  • Measure current performance and express your application's performance goals.
  • Compare other hardware or software combinations against the baseline.
  • Measure how the workload and/or data changes over time.
  • Evaluate the peak and nonpeak usage pattern of the application. This information can be used to effectively distribute database administration activities, such as full database backup and database defragmentation during nonpeak hours.

You can use the System Monitor tool (also referred to as Performance Monitor) to create a baseline for SQL Server's hardware and software resource utilization. Similarly, you may baseline the SQL Server workload using the SQL Profiler tool, which can help you understand the average resource utilization and execution time of SQL queries when conditions are stable. You can also get snapshots of this information by using dynamic management views and dynamic management functions. You will learn in detail how to use these tools and queries in Chapters 2 and 3.

One other option is to take advantage of one of the many tools that can generate an artificial load on a given server or database. Numerous third-party tools are available. Microsoft offers SQLIO (available at http://www.microsoft.com/downloads/details.aspx?familyid=9a8b005b-84e4-4f24-8d65-cb53442d9e19&displaylang=en), which measures the I/O capacity of your system. Microsoft also has SQLIOSim, a tool for generating SQL Server–specific calls and simulated loads (available at http://download.microsoft.com/download/3/8/0/3804cb1c-a911-4d12-8525-e5780197e0b5/SQLIOSimX86.exe). Many third-party tools are available that can also help with this. If your system is not yet in production, using one of these tools to simulate a load to test the system is a very good idea.

Total Pages : 7 34567

comments