问题
I have this query:
SELECT INVOICE_NUMBER, INVOICE_SEQ_NUMBER, FILE_NUMBER, MAX(INVOICE_SEQ_NUMBER) OVER (PARTITION BY INVOICE_NUMBER) AS MAX_INV_SEQ_NUM
FROM (SELECT A.INVOICE_NUMBER, A.INVOICE_SEQ_NUMBER, B.FILE_NUMBER,
DENSE_RANK() OVER (ORDER BY A.INVOICE_NUMBER) as seqnum
FROM TABLE1 A JOIN
TABLE2 B
ON A.INVOICE_NUMBER = B.INVOICE_NUMBER AND
A.INVOICE_SEQ_NUMBER = B.INVOICE_SEQ_NUMBER
) t
WHERE seqnum <= 500;
It was working fine with 10000 records in the tables but we added more today(+30k) and planing to add even more(+250-300k) to the table. Now I am getting this error:
DB2 SQL Error: SQLCODE=-905, SQLSTATE=57014, SQLERRMC=ASUTIME;000000000007;000000009000;SYSTEM PARAMETER, DRIVER=3.65.77
Is the query not correct or is not optimized for tables with big number of records? How we should handle this? Index some columns or restructure the query?
UPDATE: apparently, I was mistaken about number of records added to the table, at this moment we have 2 million records in TABLE1 and 4 million records in TABLE2, instead of 30k I mentioned initially.
回答1:
SQL0905N, ASUTIME resource limit exceeded for query against mainframe
You hit a resource limitation problem.
Question
This document provides troubleshooting information for when your application runs a query against a DB2 UDB for z/OS database and encounters the error: SQL0905N Unsuccessful execution due to resource limit being exceeded. Resource name = "ASUTIME"...
Cause
The resource being exceeded is the ASUTIME parameter found in the DB2® Universal Database™ (DB2 UDB) for z/OS® table SYSIBM.DSNRLST01. ASUTIME specifies the maximum processor service units allowed per dynamic SQL statement (for example, SELECT, UPDATE, INSERT or DELETE).
Problem Details An example of the full error message is as follows:
COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2] SQL0905N Unsuccessful execution due to resource limit being exceeded. Resource name = "ASUTIME", limit = "000000000184" CPU seconds ("000005206074" service units) derived from "SYSIBM.DSNRLST01". SQLSTATE=57014
Answer
Rewrite the complex query so that less processor service units are consumed or increase the ASUTIME parameter. The ASUTIME parameter applies to stored procedures in addition to dynamic SQL.
来源:https://stackoverflow.com/questions/56877467/db2-performance-issue-while-executing-select-query