26.08.2019 9:49, Jiří Činčura wrote:
Hi *,
let's have this structure:
create database 'localhost:slower.fdb' user 'sysdba' password 'masterkey';
create table dummy (i integer);
set term ~;
recreate procedure foobar
as
declare cnt integer;
begin
delete from dummy;
cnt = 10;
while (cnt > 0) do
begin
insert into dummy values (:cnt);
cnt = cnt - 1;
end
delete from dummy;
end~
set term ;~
Running the block below, is reasonably fast. But...
set term ~;
execute block
as
declare x integer;
begin
x = 1000;
while (x > 0) do
begin
execute procedure foobar;
x = x - 1;
end
end~
set term ;~
...subsequent executions (inside same transaction) are getting roughly 1,5x-2x slower every execution. Looking at the fetches and database pages usage it's very likely because of the garbage the `foobar` produces.
Formally, it is not a garbage until transaction ends, at least. Note, records
is inserted and deleted in the same transaction.
After the commit the execution is at the initial time again, and then it gets
slower and slower again.
Or is this something else? And can it be improved?
In theory, engine could remove such records before transaction ends. Not sure
it will be easy to do.
In practice, you may try to re-use (update) records, in this case engine will
maintain at most one backversion per record and "garbage" will not accumulated.
Regards,
Vlad
Firebird-Devel mailing list, web interface at
https://lists.sourceforge.net/lists/listinfo/firebird-devel