Using the below approach for bulk insertions, getting performance issues in flutter app
Future<List<Object?>> bulkInsert(String tableName,List<Map<String,dynamic>> rowList) async{
final db = await instance;
int dbSaveResult = 0;
if(db!=null){
await db.transaction((txn)async {
var batch = txn.batch();
for (var rowData in rowList) {
try {
batch.insert(tableName, rowData,
conflictAlgorithm: ConflictAlgorithm.replace);
}
catch(exception){
throw "some error while insertion";
}
}
await batch.commit(continueOnError: false);
});
}
return [];}
List<Map<String,dynamic>> : Map contains 4 pairs of keys/value and list length around number of 13032, so total execution time of bulkInsert() method is 3.274 seconds in flutter.
while the same approach with same data, we are using in native [transaction support using sqlite c library] for insert/update purpose then it takes around 210 milliseconds only.
any reason, why flutter based solutions taking time? or anything wrong with given code??
Please help me with best approach if I miss something.