Hallo,
habe folgende Prozedur, welche nach dem hinzufügen des zweiten JOINS sehr langsam ist. Wo gibt es Optimierungsmöglichkeiten?:
Delphi-Quellcode:
procedure Tdata.getCatalog(var ioList : TDocxDocument; inList : TStringList; language : integer=1);
var
i : integer;
tmp : TDocxline;
begin
ioList.Clear;
if workQuery.Active then WorkQuery.Active := false;
workQuery.SQL.Clear;
workQuery.SQL.Add('SELECT ass.level, ass.article_id, ass.additional_position, ass.mcount, ass.img, trans.name, art.number, art.type FROM ');
workQuery.SQL.Add('assignments as ass JOIN articles as art ON ass.article_id=art.id JOIN translations as trans ON trans.article_id=art.id WHERE');
workQuery.SQL.Add('trans.language_id=:lng AND ass.id=:id');
for i := 0 to inlist.Count - 1 do
begin
workQuery.ParamByName('id').AsInteger := StrToInt(inList[i]);
workQuery.ParamByName('lng').AsInteger := language;
workQuery.Open;
if not workQuery.IsEmpty then
begin
tmp.level := workQuery.FieldByName('level').AsInteger;
tmp.article_id := workQuery.FieldByName('article_id').AsInteger;
tmp.additional_position := workQuery.FieldByName('additional_position').AsInteger;
tmp.mcount := workQuery.FieldByName('mcount').AsInteger;
tmp.img := workQuery.FieldByName('img').AsString;
tmp.article_name := workQuery.FieldByName('name').AsString;
tmp.article_number := workQuery.FieldByName('number').AsString;
tmp.article_type := workQuery.FieldByName('type').AsString;
ioList.AddRange(tmp);
end;
workQuery.Close;
end;
end;
Danke ...