The problem is clustered index scanning to verify the foreign key.
When the deletion succeeds and there are no corresponding entries that could lead to a violation, it is necessary to check all table2 . This table has 1,117,190 rows, so this is an expensive operation that can definitely benefit from the index.
The 10% score shown in the execution plan is simply an estimate based on some modeling assumptions.
The entire plan is estimated at 0.0369164 when scanned in table 2, the cost of which is 0.0036199 , and everything else takes into account the remaining 0.0332965 . However, note that for the operator of the clustered scan index, the estimated cost of the CPU is 1.22907 and the estimated cost of I / O is 10.7142 (the total amount of 11.94327 not 0.0369164 ).
The reason for this discrepancy is that the scan is under the anti semi join statement, and the scan may stop as soon as the corresponding row is found. The estimated cost of the subtree is reduced in accordance with the modeling assumption that this will happen after only a very small part of the table has been viewed.
In case there are no FK violations and the deletion succeeds, then the whole table should be scanned, so it would be more informative to use an unscaled snapshot.
If the interest is processed using the cost of 11.94327 for this operator, which represents the full scan that has occurred in practice, then this scan operator is displayed as 99.7% of the cost of the plan ( 11.94327 / (11.94327 + 0.0332965) ).
source share