Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 8392

How to speed up client deletions

$
0
0

When deleting large clients, long runtimes are often a problem. Parallelism can help, but the real bottleneck are large tables. So maybe this guide can help. The SQL statements are for Oracle databases with SAPSR3 layout, for other databases or layouts you have to modify them.

 

Manual deletion of tables

 

First of all, you need to identify large, client specific tables. E. g. in IS-U systems candidates are DFKKOP or SWWCNTP0. These tables are client specific, so you can easily find out if the table can be truncated without harming the other clients:

 

SELECT mandt, count( * ) FROM sapsr3.dfkkop GROUP BY mandt;

or

 

SELECT client, count( * ) FROM sapsr3.swwcntp0 GROUP BY mandt;

As result, you see the number of rows for each client. When only the client you want to delete has rows, you can truncate the tables beforehand. This will significantly speed up the client deletion.

 

Copy & deletion of "unbalanced" tables

 

When you identify tables, where only a few rows are contained in the clients which will remain in the system and a huge amount of rows in the client you want to delete, you can first copy all remaining rows in a new table (assuming you want to delete client 100):

 

CREATE TABLE sapsr3."dfkkop_tmp" TABLESPACE psapsr3 NOLOGGING PARALLEL 8 AS
SELECT /*+ INDEX("dfkkop" "dfkkop~0") */ * FROM sapsr3."dfkkop" WHERE mandt NOT IN ('100'):

After that, you just have to truncate the original table and insert all rows from the temp table:

 

TRUNCATE TABLE sapsr3."dfkkop";
INSERT INTO sapsr3."dfkkop" SELECT * FROM "dfkkop_tmp";
COMMIT;
ALTER INDEX sapsr3."dfkkop~0" REBUILD ONLINE;

Rebuilding the primary index is a good thing to speed up the client deletion afterwards.

 

Automation of finding tables / preparing statements

 

To be continued...


Viewing all articles
Browse latest Browse all 8392

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>