IBM Support

DB2 might choose a sub-optimal query execution plan when distribution statistics are collected on string data columns with a common prefix of more than 32 bytes.

Troubleshooting


Problem

The RUNSTATS utility can collect two types of distribution statistics: quantile statistics and frequent value statistics. Quantile statistics provide information about how data values are distributed in relation to other values. Frequent value statistics provide information about a column and the data value with the highest number of duplicates, the value with the second highest number of duplicates, etc. When you collect distribution statistics on columns containing string data with a common prefix of more than 32 bytes, the statistics can be inaccurate as a result of design limitations in the RUNSTATS utility. If you compile a query with equality or range predicates on this column, this inaccuracy can result in a sub-optimal query execution plan. Example: In the following example, table T1 contains a column of type CHAR(40) with the following data: C1 ---------------------------------------- test.test.test.test.test.test.value1 test.test.test.test.test.test.value2 test.test.test.test.test.test.value3 test.test.test.test.test.test.value3 test.test.test.test.test.test.value3 where the first 35 bytes are the same in each value. If you collect distribution statistics on this column, you will see the following data in the SYSSTAT.COLDIST catalog view COLVALUE VALCOUNT TYPE SEQNO ---------------------------------------- -------------------- ---- ------ 'test.test.test.test.test.test.val' 5 F 1 'test.test.test.test.test.test.val' 0 Q 1 'test.test.test.test.test.test.val' 5 Q 2 and for a query referencing the column in a predicate, such as SELECT C1 FROM T1 WHERE C1 < 'test.test.test.test.test.test.value2' the optimizer will estimate all rows in the table will be returned, which can be confirmed by collecting an EXPLAIN of the query.

[{"Product":{"code":"SSEPGG","label":"Db2 for Linux, UNIX and Windows"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Component":"Database Objects\/Config - Database","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"9.8;9.7;10.1;10.5","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Log InLog in to view more of this document

This document has the abstract of a technical article that is available to authorized users once you have logged on. Please use Log in button above to access the full document. After log in, if you do not have the right authorization for this document, there will be instructions on what to do next.

Document Information

Modified date:
12 June 2026

UID

swg21668238