DB2 - Problem description
Problem IT32012 | Status: Closed |
ROWID=? PREDICATE IS SLOW WHEN DB2_DEFERRED_PREPARE_SEMANTICS=YES | |
product: | |
DB2 FOR LUW / DB2FORLUW / B10 - DB2 | |
Problem description: | |
Starting with Db2 server 11.1, queries with predicates of the form ROWID=? or RID_BIT()=? may perform slowly when DB2_DEFERRED_PREPARE_SEMANTICS=YES. The problem can be seen in the explain plan, where the slow query shows a TBSCAN over the base table: 40 TBSCAN ( 2) 160.278 5 | 1000 TABLE: MYSCHEMA T Q1 A good query will show a FETCH over the base table: 1 FETCH ( 2) 0.0364 0 | 1000 TABLE: MYSCHEMA T Q1 | |
Problem Summary: | |
**************************************************************** * USERS AFFECTED: * * ALL * **************************************************************** * PROBLEM DESCRIPTION: * * See Error Description * **************************************************************** * RECOMMENDATION: * * See Local Fix * **************************************************************** | |
Local Fix: | |
The problem can be avoided with any of the following three methods: 1. Set DB2_DEFERRED_PREPARE_SEMANTICS=NO 2. Change the SQL statement to explicitly cast the parameter marker as follows: ... WHERE ROWID=CAST(? as VARCHAR(16) FOR BIT DATA) 3. In the application, explicitly assign a data type of VARCHAR to the parameter marker. For example, in a JDBC application, instead of PreparedStatement.setBytes(n,bytearray) use PreparedStatement.setObject(n,bytearray,java.sql.Types.VARCHAR) For this workaround, jcc property sendDataAsIs should be false(default value). | |
Solution | |
Workaround | |
**************************************************************** * USERS AFFECTED: * * ALL * **************************************************************** * PROBLEM DESCRIPTION: * * See Error Description * **************************************************************** * RECOMMENDATION: * * See Local Fix * **************************************************************** | |
Timestamps | |
Date - problem reported : Date - problem closed : Date - last modified : | 27.02.2020 02.12.2021 02.12.2021 |
Problem solved at the following versions (IBM BugInfos) | |
Problem solved according to the fixlist(s) of the following version(s) |