Page 1 of 1

Fastest way to search in a dataitem

Posted: Thu Dec 14, 2017 11:44 am
by 18680079
Hello.
Can you tell me, what is the fastest way to search for a specific dataitem value.
Lets say I have invoices and invoice positions in a dataitem and want to find all invoiceppositions for invoice xy?
Should I use filters or queries?
Or is any of the possibilites as fast as the other?

Thanks.

Re: Fastest way to search in a dataitem

Posted: Mon Dec 18, 2017 2:37 pm
by yeray
Hello,

I'd use a Query with a Filter as in the Speed example:

Code: Select all

procedure TBISpeedTest.SQL1_Proc;
var Query : TDataSelect;
    Alex : TDataItem;
begin
  Query:=TDataSelect.Create(nil);
  try
    Query.Add(Persons); // * all fields

    Query.Filter:=TDataFilter.FromString(Persons,'Name="Alex"');

    // Execute Query and after that, just destroy results
    Alex:=Query.Calculate;
    Alex.Free;

  finally
    Query.Free;
  end;
end;

Re: Fastest way to search in a dataitem

Posted: Mon Dec 18, 2017 2:41 pm
by 18680079
Ok.
Thanks Yeray.