用大富翁的离线数据测试了一下发现对于Access数据库,性能比是这样的。
ADO(Jet4.0) : BDE : DAO = 140 : 70 : 26 (实际所需要的秒数)
测试是先取出人名,在按人名一个一个做查询。尽量减少cache的影响。
procedure TForm1.Button1Click(Sender: TObject);
var
s:string;
d,e:TDateTime;
begin
d:=now;
labinfo1.caption:=DateTimetostr(d);
ADODataSet1.Active:=False;
s:='select distinct userfrom from letters ';
ADODataSet1.CommandText :=s;
ADODataSet1.Active:=True;
while not ADODataSet1.Eof do
begin
s:='select * from letters where userfrom="'+ADODataSet1.fieldbyname('userfrom').AsString+'" order by datetime';
ADODataSet2.active:=False;
ADODataSet2.CommandText:=s;
ADODataSet2.active:=True;
ADODataSet1.Next;
end;
e:=now;
labinfo2.Caption:=DateTimeTostr(e);
labinfo3.Caption:=floattostr((e-d)*86400);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
s:string;
d,e:TDateTime;
begin
d:=now;
labinfo1.caption:=DateTimetostr(d);
ADODataSet1.Active:=False;
s:='select distinct userfrom from letters ';
Query1.SQL.Text:=s;
Query1.Active:=True;
Query1.First;
while not Query1.Eof do
begin
s:='select * from letters where userfrom="'+Query1.fieldbyname('userfrom').AsString+'" order by datetime';
Query2.active:=False;
Query2.SQL.Text:=s;
Query2.active:=True;
Query1.Next;
end;
e:=now;
labinfo2.Caption:=DateTimeTostr(e);
labinfo3.Caption:=floattostr((e-d)*86400);
end;
procedure TForm1.Button3Click(Sender: TObject);
var
s:string;
d,e:TDateTime;
begin
d:=now;
labinfo1.caption:=DateTimetostr(d);
ADODataSet1.Active:=False;
s:='select distinct userfrom from letters ';
DAOQuery1.SQL.Text:=s;
DAOQuery1.Active:=True;
daoQuery1.First;
while not DAOQuery1.Eof do
begin
s:='select * from letters where userfrom="'+DAOQuery1.fieldbyname('userfrom').AsString+'" order by datetime';
DAOQuery2.active:=False;
DAOQuery2.SQL.Text:=s;
DAOQuery2.active:=True;
DAOQuery1.Next;
end;
e:=now;
labinfo2.Caption:=DateTimeTostr(e);
labinfo3.Caption:=floattostr((e-d)*86400);
end;