Einzelnen Beitrag anzeigen

nahpets
(Gast)

n/a Beiträge
 
#6

AW: Kleiner Geschwindigkeitstest von Insert

  Alt 18. Dez 2016, 14:55
Hier muss testzahl mal geprüft werden, ob es den Parameter Zahl gibt. Das kostet Rechenzeit.
Delphi-Quellcode:
function test7(testzahl: integer): string;
var
  a: integer;
begin
  Form1.ZQuery1.SQL.text := 'Insert into daten2 (zahl) values (:zahl);';

  for a := 1 to testzahl do begin
      Form1.ZQuery1.ParamByName('zahl').AsInteger := a;
      Form1.ZQuery1.ExecSQL;
  end;

end;
Hier muss einmal geprüft werden, ob es den Parameter Zahl gibt.
Delphi-Quellcode:
function test7a(testzahl: integer): string;
var
  a: integer;
  p: TParam;
begin
  Form1.ZQuery1.SQL.text := 'Insert into daten2 (zahl) values (:zahl);';
  Form1.ZQuery1.Prepare;
  p := Form1.ZQuery1.ParamByName('Zahl');
  for a := 1 to testzahl do begin
    p.AsInteger := a;
    Form1.ZQuery1.ExecSQL;
  end;
end;
Ergibt das 'nen messbaren Unterschied?
Delphi-Quellcode:
function test3a(testzahl: integer): string;
var
  a: integer;
  p: TParam;
begin
  Form1.ZQuery1.SQL.Text := 'begin transaction;';
  Form1.ZQuery1.ExecSQL;
  Form1.ZQuery1.SQL.Text := 'Insert into daten2 (zahl) values (:zahl);';
  Form1.ZQuery1.Prepare;
  p := Form1.ZQuery1.ParamByName('Zahl');
  for a := 1 to testzahl do
  begin
    p.AsInteger := a;
    Form1.ZQuery1.ExecSQL;
  end;
  Form1.ZQuery1.SQL.Text := 'Commit;';
  Form1.ZQuery1.ExecSQL;
end;
Hier eventuell auch?
  Mit Zitat antworten Zitat