Tuesday 28 November 2017

c# - SQLite.Net-PCL terrible performance (InsertOrReplace)

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);

});

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...