Step 2. Executing DBO.DELETE_DATASOURCE_DATA via DB2 CLI

Step 2 includes the deletion process.

Overview and parameters

CALL DBO.DELETE_DATASOURCE_DATA({param1}, {param2}, {param3})
Parameter Type Description Recommended Default
param1 INTEGER The ID of the BFI Datasource to delete (matches dbo.datasources.id). Target DataSource ID (e.g., 1)
param2 INTEGER Row chunk size per transaction commit. Defaults to 5000 if <= 0 or NULL. 5000
param3 INTEGER Controls Foreign Key constraint handling. Set to 0 to disable/enable FKs, or 1 to bypass FK toggling.

0 (Normal) / 1 (Testing)

Note: Choose this to default as 0.

Optimization & Operational Tips

Batch Size Optimization: The default size of 5,000 rows per transaction commit is optimized for environments with up to 35,000 endpoints. For larger datasets, for example ~105,000 endpoints, increase the batch size to 10,000 to improve execution performance.

The procedure invokes complete removal of the data associated with the selected datasource.

The operation consists of the following stages:

  1. Disable Foreign Keys: Alters FK constraints to NOT ENFORCED.
  2. Staging: Populates batch numbers in dbo.batch_delete_staging.
  3. Batched Execution: Loops through batches in committed chunks.
  4. Metadata Cleanup: Purges sub-dimensions & standalone tables.
  5. FK Enforce & Check Integrity: Restores referential integrity.

Execution of the Stored Procedure

Standard Execution (Full FK Disable/Enable Handling)

Runs all stages, safely disabling FKs at the beginning and re-enforcing/checking integrity at the end.
db2 TERMINATE;
CONNECT TO TEMADB;
nohup db2 "CALL DBO.DELETE_DATASOURCE_DATA(1, 5000, 0)" > db2_execution.log 2>&1 &
db2 CONNECT RESET;
cat db2_execution.log