SQLite.Net-PCL terrible performance (InsertOrReplace)

337 Views Asked by At
foreach (var tour in Tours)
            {
                await DbInstance.InsertOrReplaceAsync(tour.Guide);
                await DbInstance.InsertOrReplaceAsync(tour.Client);
            }

This block takes 6 seconds to execute !?

I have only 10 tours in Tours list and database schema is really simple. What is the problem here?

EDIT (SOLUTION):

In order to speed it up, wrap the multiple transactions like this:

await DbInstance.RunInTransactionAsync(connection =>
        {

           **YOUR FOR LOOP**
           //example
           connection.InsertAsync(tour.Guide);
        });
0

There are 0 best solutions below