SQL Server Performance Tuning Best Practices Using DPA Tool

By Staff Contributor on July 13, 2020


Query tuning is generally considered one of the fastest ways to accelerate your Microsoft SQL Server performance. System-level server performance improvement activities can be expensive and ineffective. Moreover, expert developers agree most SQL Server performance issues can be traced directly to poorly written queries and ineffective indexing rather than hardware constraints. In fact, many performance problems can only be resolved through query optimization and tuning.

SQL Server performance tuning best practices using DPA tool

Determining where to start with SQL Server performance tuning can be challenging. Query tuning isn’t an exact science; strictly speaking, there aren’t technically “right” and “wrong” answers. Instead, DBAs are expected to discover the most appropriate solution for any given circumstance or issue.

This guide will explain what SQL Server performance tuning is, why it’s important, and how you can use SolarWinds® Database Performance Analyzer (DPA) to implement SQL Server performance tuning best practices.

What Is SQL Server Performance Tuning?
Why Is SQL Server Performance Tuning Important?
SQL Server Performance Tuning Tools
SQL Server Performance Tuning Best Practices
Getting Started With SolarWinds DPA

What Is SQL Server Performance Tuning?

SQL Server performance tuning encompasses a set of processes and procedures designed to optimize relational database queries, so they can run as efficiently as possible. SQL tuning involves several elements, including identifying which queries are experiencing slowdowns and optimizing them for maximum efficiency. Numerous relational databases—including MySQL and SQL Server—will benefit from SQL tuning.

DBAs can attempt to rectify server performance problems at the system level, usually by incorporating additional memory and processors. But these measures are expensive, and they may not be effective at resolving the problem of slow queries. SQL performance tuning helps you locate poorly written SQL queries and instances of ineffective indexing. After doing so, you may find you don’t need to invest in improving hardware or technical specifications.

SQL performance tuning can be tricky, especially when performed manually. Even small adjustments can have far-reaching effects on SQL Server and database performance. For this reason, you need effective SQL Server performance tuning tools at your disposal.

Download free Managing Multiple Databases e-book

Why Is SQL Server Performance Tuning Important?

Most businesses consider storage and information access to be primary functions. Internal and external users expect websites and applications to work quickly and effectively, which means servers and databases need to function as efficiently as possible.

A query delay of a few milliseconds may not seem like much, but it can quickly add up if each of your database queries is experiencing a similar delay. Combine this with huge amounts of continually generated data and retrieving information from a database can become time-consuming. When business-critical operations become slow, the entire business’s functionality will likely be impacted.

Successful SQL tuning requires DBAs to stay on top of SQL Server performance and ensure database-related processes run smoothly.

SQL Server Performance Tuning Tools

SQL Server performance tuning tools help users improve the performance of their indexes, queries, and databases. They provide recommendations regarding indexes potentially needing to be added, deleted, or modified to optimize performance issues. SQL Server data tools monitor performance in real time and may include tuning advisors to provide guidance on server partitions and indexed views. Some SQL Server performance tuning tools also generate statistics on the steps involved in query executions, which assists with identifying and optimizing database and server performance problems.

dpa-table-tuning

SolarWinds Database Performance Analyzer was created to remove much of the guesswork traditionally associated with SQL Server optimization. It provides continuous monitoring and combines response time analysis with historical trend analysis and logs, helping you establish performance baselines. With DPA, you can rapidly detect anomalous behavior, and the tool’s machine learning capabilities mean it’ll become more intelligent and intuitive over time.

DPA includes an integrated table tuning advisor designed to help you take advantage of hidden SQL Server optimization opportunities. The tool informs your tuning choices by analyzing queries and plans to identify tables with inefficient SQL queries. It features a built-in SQL performance analyzer giving you detailed insight into inefficient SQL statements accessing tables, with analysis results ranked by relative workload.

The DPA query performance analyzer function collects key data about a query and displays it in an intuitive and easy-to-interpret dashboard view. This utility assembles charts, so you can quickly and easily address identified performance problems. DPA also features customizable reports and alerts, keeping you informed while offering you insight into block hierarchies and how blocking can impact performance.

You can download a free trial of DPA here.

SQL Server Performance Tuning Best Practices

Effective SQL Server performance tuning starts with locating slow queries or queries not running at an appropriate level of efficiency or speed. SQL tuning can be a proactive or a reactive process. Proactive SQL Server performance tuning techniques are aimed at preventing predictable issues from occurring in the future. Reactive SQL Server performance tuning techniques respond to issues when they occur.

Generic SQL Server performance tuning best practices include:

  • Indexing with care: Indexes are data structures designed to facilitate retrieval, letting you select rows quickly. To avoid bottlenecks, indexing should be performed carefully.
  • Avoiding coding loops: This means avoiding overloading and repetition when querying.
  • Avoiding correlating SQL subqueries: Subqueries are the parent query, and they’re run row by row. This can be a slow process.

Wait times and statistics offer a great way to determine where you should focus your tuning efforts. SQL Server manages user requests as “threads.” By monitoring thread performance, DBAs are better able to identify the queries not performing as they should. Remember, the tuning process aims to reduce response time (the time between a statement and a response) and optimize throughput (the amount of resources required to process a statement).

To drill down to the cause of a SQL Server performance problem, DBAs need insight into all database and server layers. SQL Server performance tuning tools can help you expedite and streamline your tuning processes, giving you a better understanding of top SQL statements, blocked queries, wait types, and how missing indexes impact server or database performance.

The following SQL Server performance tuning best practices can be used with SolarWinds DPA to optimize your server and database performance:

  1. Conduct Response Time Analysis

Response time analysis is a pragmatic approach to optimizing SQL Server query performance, allowing you to deliver noticeable results. Also called wait time analysis, this process allows IT teams to better align their service-level delivery efforts for their customers. Instead of watching server health and guessing at the impact it’ll have on performance, wait methods analyze the actual time it takes to finish an operation. SolarWinds DPA makes response time analysis a priority.

  1. Analyze How Resource Provisioning Affects Response Times

DPA helps you align resource provisioning with database performance, allowing you to take a more prescriptive approach to hardware recommendations. You can use the SQL query analyzer to identify how resource provisioning impacts response times. This feature also helps developers gain a unique perspective on their VMware infrastructure and how it interacts with overall database performance.

  1. Analyze Historical Trends

DPA offers a historical data repository designed to highlight trends and anomalies—easy candidates for your SQL tuning efforts. DPA gives you insight into a wide range of historical data (from five seconds ago to five years ago), helping you identify and quickly resolve performance issues and bottlenecks.

  1. Know Tables and Row Counts

When you’re implementing SQL Server performance tuning techniques, make sure you’re operating on a table rather than a view or table-valued function. Table-valued functions have different performance implications. The Table Tuning Advisor feature in DPA can provide table row count, churn, index fragmentation, and other aggregated information about the table.

  1. Examine Query Filters, Clauses, and Row Count

If there aren’t any filters and most of the table is returned, you may want to consider whether all the data included is strictly necessary. If there are no filters at all, this might indicate an issue, and you should investigate further. This can slow a query down significantly.

  1. Understand Table Selectivity

If you’ve implemented the two previous tips, you should know how many rows you’ll be working with or the size of the actual, logical set. To ensure your tuning efforts are appropriate, it’s key for you to have a comprehensive understanding of table selectivity. Using SQL diagramming to assess queries and query selectivity is also recommended. This is a useful and powerful tool.

  1. Analyze Additional Query Columns

To determine whether extra columns are involved, examine the SELECT* or scalar functions carefully. The more columns brought back, the less optimal it may become for an execution plan to utilize certain index processes. This can result in degraded performance.

  1. Understand Constraints

When you start the tuning process, knowing and using constraints can be useful. It’s important for you to review existing keys, indexes, and constraints to avoid duplicating efforts or overlapping existing indexes. If you want to get more information on your indexes, you can run the sp_helpindex stored procedure. DPA will give you in-depth and continual insight into your indexes.

  1. Examine the Execution Plan

Estimated plans utilize approximated statistics to figure out the estimated rows; actual plans, on the other hand, use actual statistics at runtime. If the estimated plan is different from the actual plan, this may be a reason to investigate the issue further. DPA is built to list each execution plan that it finds, providing you with the ability to click a link to examine the full plan and steps with the most inefficient access paths that may need attention.

  1. Record Results

When conducting SQL Server performance tuning, make sure you’re recording your results. This will allow you to determine the true impact of any changes made.

  1. Adjust Queries

Making too many changes at once can be ineffective, as the changes can cancel each other out. Start by looking for the most expensive operations—remember, there’s no official “right” answer. Instead, endeavor to find the optimal solution for the given situation.

  1. Rerun Query and Record Results

If you see an improvement in logical I/Os but the improvement isn’t significant enough, you’ll need to examine other elements you may need to adjust. Make one change at a time, rerun the query, and compare your results. Repeat this process until you’re satisfied you’ve addressed and rectified all the expensive operations you can.

  1. Adjust Indexes

Adding or modifying indexes isn’t always the best thing for DBAs to do. However, if you can’t alter the code, this may be your only option. Consider improvements you can make to existing indexes, a covering index, and a filtered index. If you’ve made modifications, rerun the query, record the results, and compare them to earlier versions.

  1. Identify Potential Performance Inhibitors

Keep an eye out for performance inhibitors occurring more than once. This might include code first generators, scalar functions, cursors, nested views, abuse of wildcards, and row-by-row processing.

Getting Started With SolarWinds DPA

The SQL Server performance tuning best practices set out in this guide can be performed with or without tuning tools. However, implementing these techniques manually can be a time-consuming and error-prone process. To streamline your SQL Server performance optimization efforts and set them up for success, SolarWinds DPA comes highly recommended.

SolarWinds DPA is an advanced and user-friendly tool you can use to streamline the implementation of SQL Server performance tuning best practices like the ones listed above. It’s a highly versatile and sophisticated solution featuring machine learning capabilities and detailed analysis tools. The response time analysis feature is especially useful, helping you identify bottlenecks, pinpoint the root cause of issues, and prioritize actions based on impact analysis. This is one of the best SQL Server performance tuning tools on the market. You can access a 14-day free trial here.

 

Related Posts