|
|
 |
Blogs Toad and Database Commentaries |
Toad World blogs are a mix of insightful how-tos from Quest experts as well as their commentary on experiences with new database technologies. Have some views of your own to share? Post your comments! Note: Comments are restricted to registered Toad World users.
Do you have a topic that you'd like discussed? We'd love to hear from you. Send us your idea for a blog topic.

 |
 |
|
|
 |
 |
Location: Blogs
Richard To's Blog
|
|
| RichardTo |
Friday, July 10, 2009 5:33 AM |
Written by Rene Woody
This blog is a continuation of a series about test running the SQL statements in the Tuning Lab in Quest SQL Optimizer for Oracle to find the best performing SQL statement in your database environment. It covers executing SQL statements that require you to enter a parameter before the SQL statements are executed.
A SQL statement with a variable that is provided at run time poses an extra challenge when trying to determine which alternative SQL statement is going to give the best overall performance. Each time the SQL statement is executed, a different variable could be supplied.
You may find that when you use one variable, alternative 1 has the best elapsed time and when you use another variable, maybe alternative 2 has the best elapsed time. So, how can you determine which SQL statement to use in the application?
This diagram shows two SQL statements (SQL1 and SQL2) plus the performance time and the retrieved data volume relationship.

If you look at the performance of the SQL statements to the left of the Meet Point (the point where the two lines intersect), you can see that when the variable that is used produces a lower data volume that falls into the range to the left of the Meet Point, SQL 2 has the best performance.
So in this example, let’s say that the first variable that you test falls into the left range of Meet Point, and therefore SQL2 gives better performance than SQL1. Then the second variable that you test selects more data and falls into the data volume range that is to the right of the Meet Point. In this second test, SQL1 provides the best performance. The big challenge when doing performance tuning for a SQL statement which requires a variable is that there is no single winner between SQL1 and SQL2 for entire data set.
Two factors should be considered when choosing the SQL statement for your application. The first criterion that you should use to pick the “best” SQL statement is the best fit for most of the variables that will likely to be used when this SQL statement is executed. Another selection criterion is that there should not be a rapid rise in the performance time after the Meet Point. For this example, SQL1 is likely to be a better overall choice rather than SQL2, since there is a rapid growth on the right-hand side of the Meet Point for SQL2. SQL1 will provide a more consistent performance throughout the entire data set.
|
|
| Permalink |
Trackback |
|
 |
 |
|
 |
|
 |
|
|