How to batch INSERT and UPDATE

Issue #233 on hold
Sergey Burov created an issue

how to use batch inserts with ORM and firedac ( for example postgresql),

is it possible

      qryBatch.Params.ArraySize := StrToInt(edtArraySize.Text);
      iTm := GetTickCount;
      for i := 0 to qryBatch.Params.ArraySize - 1 do begin
        qryBatch.Params[0].AsIntegers[i] := i;
        qryBatch.Params[1].AsStrings[i] := 'string' + IntToStr(i);        
      end;
      Execute(qryBatch.Params.ArraySize);
      iTm := GetTickCount - iTm;

in my test this code 200 times faster at 10,000 entries

thanks for answer

Comments (7)

  1. Stefan Glienke repo owner

    Not supported because the ORM is agnostic of what the data access components support (Array DML is a FireDAC feature) and currently does not support batch operations at all.

    If you look at TSession.InsertList for example you see that it does DoInsert for each item in the list.

  2. Log in to comment