rspec/rules/S3830/rule.adoc

33 lines
978 B
Plaintext
Raw Normal View History

2020-06-30 12:48:39 +02:00
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.
2021-02-02 15:02:10 +01:00
2021-01-27 13:42:22 +01:00
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.
2020-06-30 12:48:39 +02:00
2021-02-02 15:02:10 +01:00
2021-01-27 13:42:22 +01:00
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.
2020-06-30 12:48:39 +02:00
== Noncompliant Code Example
2022-02-04 17:28:24 +01:00
[source,text]
2020-06-30 12:48:39 +02:00
----
FOR item IN itemlist
LOOP
-- ...
COMMIT; -- Noncompliant
END LOOP;
----
== Compliant Solution
2022-02-04 17:28:24 +01:00
[source,text]
2020-06-30 12:48:39 +02:00
----
FOR item IN itemlist
LOOP
-- ...
END LOOP;
COMMIT;
----