我有这个查询:
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;
它在表格中有 10000 条记录时运行良好,但我们今天添加了更多(+30k)并计划在表格中添加更多(+250-300k)。现在我收到此错误:
DB2 SQL Error: SQLCODE=-905, SQLSTATE=57014, SQLERRMC=ASUTIME;000000000007;000000009000;SYSTEM PARAMETER, DRIVER=3.65.77
查询是否不正确或未针对具有大量记录的表进行优化?我们应该如何处理?索引某些列或重组查询?
更新:显然,我对添加到表中的记录数有误,此时我们在 TABLE1 中有 200 万条记录,在 TABLE2 中有 400 万条记录,而不是我最初提到的 30k。