rspec/rules/S3830/rule.adoc

35 lines
1006 B
Plaintext

== Why is this an issue?
Frequent commits are widely understood to negatively impact performance. Thus, committing inside a loop (even when only executed conditionally once every n iterations) is highly likely to cause unwanted performance impacts.
Further, in general use ``++COMMIT++`` should only be used at the end of a transaction. Code that is not structured to have one transaction per loop iteration could yield unexpected results if ``++COMMIT++`` is nonetheless used inside the loop. Code that _is_ structured to have one transaction per loop iteration should probably be reconsidered.
Note that when dealing with very large data sets, a ``++COMMIT++`` may be required every n iterations, but the goal should be to avoid ``++COMMIT++``s inside loops.
=== Noncompliant code example
[source,text]
----
FOR item IN itemlist
LOOP
-- ...
COMMIT; -- Noncompliant
END LOOP;
----
=== Compliant solution
[source,text]
----
FOR item IN itemlist
LOOP
-- ...
END LOOP;
COMMIT;
----