Subject Re: [firebird-support] Re: Firebird on Windows
Author Artur Anjos
Ivan Prenosil wrote:
> How do you find out the size of db file ?
> Windows explorer has some cacheing; you eihter have to
> explicitely look at Properties of the file, or select (click at the) db file
> and then do refresh.

Ivan,

Some weeks ago we did discuss this in CFLP.
I did a "small and dirty" test using Delphi, using FindFirst to collect
size info:

Environment:
- Firebird 1.0, W2K, TCP/IP connection to localhost
- EMPLOYEE.GDB to run the tests. I just created a new table - TEST -
with a varchar(1024) field.

Using IBO, IB_Con is a TIB_Connection, TIB_DSQL1 is a TIB_DSQL, simple
statement, just to insert some data [ insert into teste (testing) values
AVeryLongStringHere ]

Here is the code:

procedure TForm1.ShowSize;
var
sr: TSearchRec;
begin
if FindFirst( 'D:\data\GSTGC.FDB', faArchive, sr) = 0 then
Memo1.Lines.Add( '-----> ' + IntToStr( sr.Size ) );
FindClose( sr );
end;

procedure TForm1.Button1Click(Sender: TObject);
var
ii : integer;
begin

Memo1.Clear;
Memo1.Lines.Add( 'Before Connect:' );
ShowSize;

IB_Con.Connect;
Application.ProcessMessages;
sleep( 3000 );
Memo1.Lines.Add( 'After Connect:' );
ShowSize;

IB_DSQL1.Prepare;
for ii:=0 to 10000 do
begin
IB_DSQL1.ExecSQL;
end;
IB_DSQL1.Unprepare;
Application.ProcessMessages;
sleep( 3000 );

Memo1.Lines.Add( 'After Insert:' );
ShowSize;

IB_Con.Close;
Application.ProcessMessages;
sleep( 3000 );
Memo1.Lines.Add( 'After Disconnect:' );
ShowSize;

Memo1.Lines.SaveToFile( 'd:\gastao.txt' );


end;

Here are the first results:

Before Connect:
-----> 1032192
After Connect:
-----> 1032192
After Insert:
-----> 1032192
After Disconnect:
-----> 1032192

And if I run it twice:

Before Connect:
-----> 1032192
After Connect:
-----> 3518464
After Insert:
-----> 3518464
After Disconnect:
-----> 3518464

And so on, if we repeat this.

Nice results, aren't they ? ;-)

Well, if I got these results in code, I'm pretty sure that Windows
Explorer will not see the differences either. But we do believe that
Firebird flushes all writes - we know the code, we see the performance
decrease, etc. We just don't see the results.

Do you know any other method in Delphi that I can use to get the file
size ( without opening it, of course ) instead of FindFirst? I believe
that some "smart cache" in Windows are keeping us to see real size info,
I just don't know how to prove it. :-)

Artur