This is a continuation of last week's post.
Avoid Inappropriate Tablespace Scans
There are many DB2 access paths available. The most expensive of these is a tablespace scan because it causes DB2 to scan all the entries of a table to retrieve the rows desired by the application. Within most of the system and application performance reviews done at one recent client's review, there were 1,869 distinct existing tablespace scans in their production environment. Almost one tenth of the applications were doing tablespace scans. This was significantly worse than that found at other clients or industry standards.
In addition to accessing every row within a table, these tablespace scans hold additional database locks, consume additional CPU, and hinder application throughput performance. Each of these tablespace 1,869 scans needed to be evaluated to see if the access path could be improved. Improving all of your production tablespaces scans will reduce overall CPU and locking consumption.
List Prefetch and Index Scans
Other expensive DB2 access paths are List Prefetch and Index scans. These access paths can very often be improved and optimized to direct index access resulting in CPU savings and improve elapsed runtimes. Analyzing the production environment at a recent financial bank showed a large number (737) of the available programs doing these types of SQL access types.
When these List Prefetch and Index Scans are being used, they are pushing a number of Record Identifiers (RIDs) to the RID pool within the DB2 system. When a large number of applications push RIDs into the RID Pool sometimes the pool requirements become too big causing RID pool failures. When RID Pool failures happen, the access path is degraded, causing more I/O and CPU to be used to retrieve the database information. To avoid this situation each of the index scans should be evaluated to determine if it is overflowing or causing major utilization of the RID pool.
These types of List Prefetches and Index Scans access types can sometimes be improved through using more SQL WHERE statement parameters or verifying the index definitions are appropriate. By improving the SQL, monitoring the number of rows referenced and monitoring RID Pool failures, the efficiency of the programs will be improved and the CPU reduced for each application execution.
Review applications in your company for:
- Excessive use of tablespace scans
- Excessive use of list prefetch and index scans
- Lack of use of more recent SQL techniques such as limited fetch or table expressions.
Dave Beulke is an internationally recognized DB2 consultant, DB2 trainer and education instructor. Dave helps his clients improve their strategic direction, dramatically improve DB2 performance and reduce their CPU demand saving millions in their systems, databases and application areas within their mainframe, UNIX and Windows environments.