2

I create a SQLite database for mobile application with third party application in C# language. I insert map data in database. it is very slow and lazy in inserting data (map tiles) and take long time for inserting data. Is there any recommendation in database creation to increase write speed of SQLite database? (for example size of database file or create cache file or ...)

This is my connection string builder parameters:

SQLiteConnectionStringBuilder conString = new SQLiteConnectionStringBuilder();
conString.DataSource = databaseFileName;
conString.DefaultTimeout = 5000;
conString.FailIfMissing = false;
conString.ReadOnly = false;
Mohamed Salemyan
  • 691
  • 2
  • 15
  • 31

1 Answers1

4

I had found some connection string settings that extremely increase my insert speed:

Connection string for better performance:

SQLiteConnectionStringBuilder conString = new SQLiteConnectionStringBuilder();
conString.DataSource = databaseFilePath;
conString.DefaultTimeout = 5000;
conString.SyncMode = SynchronizationModes.Off;
conString.JournalMode = SQLiteJournalModeEnum.Memory;
conString.PageSize = 65536;
conString.CacheSize = 16777216;
conString.FailIfMissing = false;
conString.ReadOnly = false;
Mohamed Salemyan
  • 691
  • 2
  • 15
  • 31
  • Which file are you referencing? Microsoft.Data.Sqlite? System.Data.Sqlite? – Mehdi Anis Feb 25 '20 at 18:40
  • Dear Mehdi Microsoft.Data.Sqlite release date is 6/27/2016 and my question date is 4/09/2014. Off course i use System.Data.Sqlite.Thanks for your appropriate question. – Mohamed Salemyan Feb 26 '20 at 07:58
  • 1
    Microsoft.Data.Sqlite does not have connection string keyword for journal mode. you should set this parameters with command object. – Mohamed Salemyan Feb 26 '20 at 09:56
  • Thanks Mohammed Salemyan. I am using System.Data.Sqlite and can load 7Million lines with 14 columns in 16 minutes. I am using Batch Insert of 10,000 rows at a time using Transaction. – Mehdi Anis Feb 28 '20 at 15:20