Reputation: 3
Introduction: I work on DB2 databases in one of my projects. In one of the databases, a job that executes an SQL is running.
Problem: For the past few days, this job has been failing with the below error code.
-101 THE STATEMENT IS TOO LONG OR TOO COMPLEX
Description:
Query is optimized to class 7.
Query consists of a select statement with complex and multiple joins. This select statement is used to insert data into a table. ex:
INSERT INTO table_name (column_name_1, column_name_2, ....)
SELECT * from table_name_1 t1 join table_name_2 t2 on t1.col_1=t2.col_2;
However, the joins are much more lengthy and complex. Plus, a large number of columns are involved.
This query was running for a long time in the system but never failed. This query was also never changed.
The number of record counts in the source tables is also reducing with each passing day because the application is about to get decommissioned.
Solution Attempts:
Based on this I doubled the STMTHEAP value and the query ran but it failed again the next day. I further doubled the STMTHEAP value and then it ran but it failed again the next day. This is going on till date.
Other resources that I used:
https://www.ibm.com/docs/en/db2/11.1?topic=parameters-stmtheap-statement-heap-size
https://www.ibm.com/docs/en/ias?topic=parameters-sortheap-sort-heap-size
Ask: Can any of you help me resolve this issue?
Upvotes: 0
Views: 575