简体   繁体   English

如何减少 IBM db2 中的删除时间

[英]How to decrease deletion time in IBM db2

We are using IBM db2, trying to delete 200000 data from different tables, using stored procedure invoked through java code.我们正在使用 IBM db2,尝试使用通过 java 代码调用的存储过程从不同的表中删除 200000 条数据。 It's taking 75+ hours to delete, suggest ways to optimize the deletion time.删除需要 75 多个小时,建议优化删除时间的方法。 we can't stop the log for the deletion.我们无法停止删除日志。 we can't use the truncate feature.我们不能使用截断功能。

Something like this is one way像这样的事情是一种方式

/*
 * Example of deleting X rows of data at a time from a table to avoid e.g. transaction log full on row organized talbes
 * 
 */

BEGIN
    DECLARE DONE  BOOLEAN DEFAULT FALSE;  
    --
    DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' BEGIN SET DONE = TRUE; END;
    --
    WHILE NOT DONE
    DO
        DELETE FROM (SELECT * FROM MY_TABLE WHERE COL1 = 'A' FETCH FIRST 20000 ROWS ONLY)
        COMMIT;
    END WHILE;
END

You could also consider using MDC tables to allow " rollout " deletion, or other physical design optimizations您还可以考虑使用 MDC 表来允许“ 推出”删除,或其他物理设计优化

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM