#1 mORMot 1 » Newbie question on mORMot low level SQLITE access and speed » 2015-01-24 12:33:24

maestro3
Replies: 1

Hello, I am a hobby programmer and I compared the performance of FireDac in DXE7 with mORMot framework with low level access. I did not really use the ORM framework, but looked for a wrapper for SQLite which may also work with FP under Linux. For this test I created a table and later inserted records from an existing Microsoft Access database using ADO components in both cases.

With FireDac the insert process took about 2-86ms (measured the min & max values) per record with the FireDac statement object. Using a Prepare and later bind parameters to it.
In code

  FStmnt.Prepare('INSERT INTO "Attenuation Coefficients" (ID, En, EnComment, MuOverRho, MuEnOverRho)' +
                        ' VALUES (:ID, :En, :EnComment, :MOR, :MEOR)');
    for i := 1 to FStmnt.ParamDefsCount do 
      TSQLiteBind.Create(FStmnt.Params);
   while not(DM.ADOTbl.Eof) do begin
      FStmnt.Params[0].AsInteger:=DM.ADOTbl.FieldByName('ID').AsInteger;
      FStmnt.Params[1].AsFloat:=DM.ADOTbl.FieldByName('En').AsFloat;
      FStmnt.Params[2].AsString:=DM.ADOTbl.FieldByName('EnComment').AsString;
      FStmnt.Params[3].AsFloat:=DM.ADOTbl.FieldByName('MuOverRho').AsFloat;
      FStmnt.Params[4].AsFloat:=DM.ADOTbl.FieldByName('MuEnOverRho').AsFloat;
      FStmnt.Execute;
      FStmnt.Reset;
      DM.ADOTbl.Next;
    end;
 

With mORMot the insert process took between 80-180ms per record so substancially longer than FireDac. In both cases I used statically linked Sqlite3 (probably not the same version).
This is mORMot's code

  SynStmt.Prepare('INSERT INTO "Attenuation Coefficients" (ID, En, EnComment, MuOverRho, MuEnOverRho) ' +
                          'VALUES (:ID, :En, :EnComment, :MOR, :MEOR)');
  while not(DM.ADOTbl.Eof) do begin
    SynStmt.Bind(1, DM.ADOTbl.FieldByName('ID').AsInteger);
    SynStmt.BindVariant(2, DM.ADOTbl.FieldByName('En').AsFloat, False);
    SynStmt.BindTextS(3, DM.ADOTbl.FieldByName('EnComment').AsString);
    SynStmt.BindVariant(4, DM.ADOTbl.FieldByName('MuOverRho').AsFloat, False);
    SynStmt.BindVariant(5, DM.ADOTbl.FieldByName('MuEnOverRho').AsFloat, False);
    SynStmt.ExecutePrepared;
    SynStmt.Reset;
 end;
 

Now the questions are:
  1) Could this be a SQLITE version issue?
  2) Do I use the wrong objects in mORMmot for this simple task?
  3) Or is mORMmot not really designed for this kind of low level access and the loss in speed is due to the ORM framework overhead?

Board footer

Powered by FluxBB