by Richard Smith >> Tue, 1 Jun 1999 0:44:37 GMT
Something we discovered recently is the large overhead in doing abegin /commit transaction. The following method illustrates quite clearly.
test();
vars
dat : RJSData; // a persistent with one attribute (id : Integer)
i : Integer;
begin
i := 1;
beginTransaction;
while i <= 1000 do
i := i + 1;
// beginTransaction;
create dat;
dat.id := i;
// commitTransaction;
endwhile;
commitTransaction;
end;
With the begin/commit inside the while loop this took about 20-25 seconds to execute and resulted in 4000-4500k being written to the logfile.
Moving the begin/commit to outside the while loop reduced the time to 1 second and only 200-250k was written to the logfile.
The main point to consider with transactions is "What should be undone if the application fails?". This would effect if you ideally want thebegin /commit inside or outside the loop but the above test shows that there
is a large overhead if this is within the loop.