O teste é comprar mesmo, se usando o DBX e Oracle, se o 2007 é mais rápido na execução de uma determinada query, como falei acima. Neste caso, o D7 tem sido mais rápido. Quero dizer, que fiz o mesmo programa, igualzinho mesmo e no D7 ficou de um tamanh e no 2007 outro, para o mesmo programa.
O que está abaixo, é o que eu fiz para ambas as versões do Delphi(7 e 2007), claro que fiz várias mudanças, como ParamByName, Params, carregar a Sql dentro e fora do laço, trabalhei com valores reais e não reais, e sempre o 7 ganhando, sendo mais rápido.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, WideStrings, FMTBcd, StdCtrls, DB, SqlExpr;
type
TForm1 = class(TForm)
SQLConnection1: TSQLConnection;
SQLQuery1: TSQLQuery;
Button1: TButton;
Label1: TLabel;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
tempo: TTime;
i : Integer;
begin
Button1.Enabled := False;
tempo := now;
i := 1;
for i := 1 to 10000 do
begin
sqlquery1.Close;
sqlquery1.Sql.Text :=
´Select epempsis, epmatricula, epdata, eptipo, epautoinc ´ +
´From EntrPont ´ +
´Where epempsis = 1 and epmatricula = 222´ +
´and eptipo = ´´A´´and epautoinc = 0´;
sqlquery1.Active := True;
end;
Label1.Caption := ´Tempo Gasto: ´ + FormatDateTime(´HH:MM:SS´, now-tempo);
Button1.Enabled := True;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
tempo : TTime;
i : integer;
sql : string;
dt : TDateTime;
begin
Label1.Caption := ´Tempo Gasto: 00:00:00´;
Button2.Enabled := False;
tempo := now;
i := 1;
dt:= trunc(now);
sql := ´Select epempsis, epmatricula, epdata, eptipo, epautoinc ´ +
´From EntrPont ´ +
´Where epempsis = :emp and epmatricula = :mat ´ +
´and epdata = :dt ´ +
´and eptipo = :tipo and epautoinc = :auto´;
SQLQuery1.Sql.Text := sql;
for i := 1 to 10000 do
begin
SQLQuery1.Close;
SQLQuery1.Params[0].AsString := ´1´;
SQLQuery1.Params[1].AsString := IntToStr(i);
SQLQuery1.Params[2].AsString := DateToStr(Date+1);
SQLQuery1.Params[3].AsString := ´A´;
SQLQuery1.Params[4].AsString := ´0´;
SQLQuery1.Active := True;
end;
Label1.Caption := ´Tempo Gasto: ´ + FormatDateTime(´HH:MM:SS´, now-tempo);
Button2.Enabled := True;
end;
end.