< Day Day Up > |
Understanding the ins and outs of DB2 performance can be an overwhelming task. DB2 tuning options are numerous and constantly changing. Even the number of SQL tuning options is staggering. The differences in efficiency can be substantial. For example, coding a query as a join instead of as a correlated subquery sometimes results in a query that performs better. The same query, however, might result in degraded performance. Plus, to make matters worse , a new version or release of DB2 can cause completely different results. NOTE Although a new release rarely causes the results set of a query to change, the performance results can change dramatically. And sometimes even the query's answer can change if, for example, a default changes. IBM works diligently to make sure this does not happen, though. The release level of DB2 is not the only factor that can cause performance problems. Changes to the z/OS or OS/390 operating system, the DB2 database environment, the application code, or the application database can cause performance fluctuations. The following is a sample list of system changes that can affect DB2 query performance:
Luckily, you can prepare yourself to deal with performance problems by understanding the dynamic nature of DB2 performance features and keeping abreast of SQL tricks of the trade. Use caution when implementing these tips and tricks, though, because the cardinal rule of relational database development always applies ”what is this cardinal rule? NOTE The cardinal rule of RDBMS development is "It depends!" Most DBAs and SQL experts resist giving a straight or simple answer to a general question because there is no simple and standard implementation that exists. Every situation is different, and every organization is unique in some way. Don't be discouraged when you ask the local expert which statement will perform better, and the answer is "It depends." The expert is just doing his or her job. The secret to optimizing DB2 performance is being able to answer the follow-up question to "It depends" ”and that is "What does it depend on?" The key to effective SQL performance tuning is to document each SQL change along with the reason for the change. Follow up by monitoring the effectiveness of every change to your SQL statements before moving them into a production environment. Over time, trends will emerge that will help to clarify which types of SQL formulations perform best. This chapter is divided into six major sections. In the first section, you learn SQL guidelines for simple SQL statements. The second section covers guidelines for complex SQL statements such as joins, subqueries, table expressions, and unions. Common table expressions and recursion are introduced in section three; these features are new to DB2 V8 and they require some effort to master. Section four introduces the concept of nulls. Section five deals with querying date, time, and timestamp values. The sixth section provides guidelines for the efficient use of the INSERT , DELETE , and UPDATE statements. |
< Day Day Up > |