Subject | Re: Firebird Sleeping |
---|---|
Author | lseckde |
Post date | 2005-04-22T09:14:37Z |
--- In firebird-support@yahoogroups.com, "Ann W. Harrison"
<aharrison@i...> wrote:
"playing" a little bit more. I found the following:
(the table 'dbt_test' has only one record in, no triggers, constraints,
calculation, ..)
1 Test
procedure CallCyclic;
var iI : Integer;
ulTick : Cardinal;
begin
ulTick := GetTickcount;
for iI := 0 to 99 do begin
if not Database1.Connected then Database1.Open;
if not Database1.InTransaction then Database1.StartTransaction;
if not Query1.Prepared then begin
Query1.SQL.Text := 'select * from dbt_test';
Query1.Prepare;
end;
Query1.Open;
Query1.Edit;
Query1.FieldByName('TID').asInteger := Random(100000);
Query1.Post;
if Database1.InTransaction then Database1.Commit;
end;
Memo1.Lines.Add(Format('Time %d',[TickDiff(GetTickCount, ulTick)]));
end;
This produces record version after record version. (seen by gstat -a -r)
I also tried to read the record with isql (start/read/close) from time
to time, but no version was removed. As the test application is the
only one that uses the DB I'm sure that there is no other transaction
around also gstat says so.
2 Test
procedure CallCyclic;
var iI : Integer;
ulTick : Cardinal;
begin
ulTick := GetTickcount;
for iI := 0 to 99 do begin
if not Database1.Connected then Database1.Open;
if not Database1.InTransaction then Database1.StartTransaction;
if not Query1.Prepared then begin
Query1.SQL.Text := 'select * from dbt_test';
Query1.Prepare;
end;
Query1.Open;
Query1.Edit;
Query1.FieldByName('TID').asInteger := Random(100000);
Query1.Post;
if Database1.InTransaction then Database1.Commit;
end;
-> Query1.Close;
Memo1.Lines.Add(Format('Time %d',[TickDiff(GetTickCount, ulTick)]));
end;
I change the program to close the query, so that the changing
application reads the record once before it changes it 100 times.
And now: The record versions are removed. With gstat I now see a
maximum of 100 Version.
But why are record version keept that are from exactely the same
transaction.
Questions over questions.
But maybe there is an simple answer to them.
Regards
Thomas
<aharrison@i...> wrote:
> lseckde wrote:Hi,
> >
> >
> > I was using isql as the second connection to read from time to time
> > the record the other application is modifying. But I closed isql
> > evertime afterwards. And I whatches the transactions there was no
> > transaction other than that one that changes the record frequently.
> >
>
> Hunh. Strange. I'll have to play with that - the act of updating a
> record in a new transaction should cause old versions to be removed.
>
> Thanks,
>
>
> Ann
"playing" a little bit more. I found the following:
(the table 'dbt_test' has only one record in, no triggers, constraints,
calculation, ..)
1 Test
procedure CallCyclic;
var iI : Integer;
ulTick : Cardinal;
begin
ulTick := GetTickcount;
for iI := 0 to 99 do begin
if not Database1.Connected then Database1.Open;
if not Database1.InTransaction then Database1.StartTransaction;
if not Query1.Prepared then begin
Query1.SQL.Text := 'select * from dbt_test';
Query1.Prepare;
end;
Query1.Open;
Query1.Edit;
Query1.FieldByName('TID').asInteger := Random(100000);
Query1.Post;
if Database1.InTransaction then Database1.Commit;
end;
Memo1.Lines.Add(Format('Time %d',[TickDiff(GetTickCount, ulTick)]));
end;
This produces record version after record version. (seen by gstat -a -r)
I also tried to read the record with isql (start/read/close) from time
to time, but no version was removed. As the test application is the
only one that uses the DB I'm sure that there is no other transaction
around also gstat says so.
2 Test
procedure CallCyclic;
var iI : Integer;
ulTick : Cardinal;
begin
ulTick := GetTickcount;
for iI := 0 to 99 do begin
if not Database1.Connected then Database1.Open;
if not Database1.InTransaction then Database1.StartTransaction;
if not Query1.Prepared then begin
Query1.SQL.Text := 'select * from dbt_test';
Query1.Prepare;
end;
Query1.Open;
Query1.Edit;
Query1.FieldByName('TID').asInteger := Random(100000);
Query1.Post;
if Database1.InTransaction then Database1.Commit;
end;
-> Query1.Close;
Memo1.Lines.Add(Format('Time %d',[TickDiff(GetTickCount, ulTick)]));
end;
I change the program to close the query, so that the changing
application reads the record once before it changes it 100 times.
And now: The record versions are removed. With gstat I now see a
maximum of 100 Version.
But why are record version keept that are from exactely the same
transaction.
Questions over questions.
But maybe there is an simple answer to them.
Regards
Thomas