It Can Be Painful to Find Your Problem SQL Statements

by Jul 30, 2019

One of the most important tasks that fall under the responsibility of your DBAs is the optimization of their SQL servers and associated databases. No one is ever fully satisfied with the performance of an application or database. There are always improvements to be made that will increase the speed at which they perform and create a more engaging end-user experience.

Many factors can influence how well a database is performing. Some of the problems can be related to the network or infrastructure on which the database operates and may be outside the purview of the DBAs. They may make recommendations designed to streamline the responsiveness of their databases but cannot institute environmental changes on their own.

A primary method by which a DBA can impact a database is through the SQL code that powers the system. It can be extremely time-consuming to attempt to tune your SQL statements. There may be some tried-and-true methods that can be used in your tuning efforts, but one question cannot be answered through any pre-defined procedures or techniques. Which are the statements that are leading to the performance degradation that you hope to resolve? Without this information, you will just be shooting in the dark and hoping you get lucky as you address your SQL code.

Profiling Your Database to Uncover Hidden Problems

The technique which can provide insight into the inner-workings of your database code is profiling. Conducting comprehensive profiling of a database can take a considerable amount of time. In the busy life of a DBA, any way to minimize the time required to perform some of their critical tasks is welcomed with open arms. The same can be said regarding making the time spent on profiling and code reviews more productive.

Trace analysis has traditionally been used to generate comprehensive and chronological lists of the SQL statements being executed inside a database. This can help find ineffective code, but it requires a DBA to write custom queries to run against the trace tables. Trace analysis is also more productive when you already have an idea of what parts of the code are affecting database performance. Unfortunately, you might still be seeking that information.

Wait-time analysis can reveal where your code is malfunctioning more expeditiously than trace analysis. Colloquially known as bottleneck analysis, this technique identifies the time delays that impact end-users and lengthen response times. It’s a more practical method of pinpointing the statements that deserve your attention when tuning your database.

Employing wait-time analysis involves analyzing a list of statements that experience time delays to locate specific statements, queries or routines which can be optimized. You stand a much better chance of successfully addressing the database performance issues when you have a clear understanding of where your slow code fragments are hiding and how often they are executed.

DB Optimizer Helps You Identify Inefficient SQL Statements

One of the components of IDERA’s DB PowerStudio is the powerful tuning and profiling tool known as DB Optimizer. It uses wait-analysis methodology to profile your SQL code and presents the information in an intuitive and user-friendly interface to facilitate your utilization of its results.

DB Optimizer categorizes wait events and displays them in an easy-to-use tab view. It’s an agentless tool that can be installed in minutes and is compatible with many RDMS platforms including SQL Server, Sybase, Oracle, and DB2. It interrogates wait events such as CPU, lock, I/O, memory and buffer. The tool offers a comprehensive application that will accelerate your database optimization efforts and return valuable time to your DBAs.

Some specific ways that DB Optimizer and wait-time analysis can be beneficial when optimizing your databases are by:

  • Enabling more productive code reviews by graphically displaying information gained through predicate analysis and showing how often similar queries are run. This helps find inefficient code that may be used repeatedly in your system.

  • Conducting profiling during development and QA testing. The ease with which you can perform profiling allows your team to test during the development and QA phases of staging a new database. This may indicate areas that can be addressed before your database goes into production.

  • Identifying production slowdowns rapidly. Even the best testing will not uncover all of the issues that become evident when your DB goes live and deals with the stresses of a real workload. DB Optimizer will find the issues in your production databases and let you fix them quickly to minimize any negative impact to your users.

If you want to fully optimize your database it will take delving into the code. DB Optimizer will point the way toward the improvements which need to be made to make your database sing.