On 25 Mar 2017, at 7:14pm, Max Terentiev <supp...@bspdev.com> wrote:

> Sqlite have many settings combinations affecting concurrency please help me
> to chose right settings for my task

1. Leave SQLITE_THREADSAFE to the default setting.

2. Leave shared cache and uncommitted reads to the default settings.

Use WAL mode.  This is a one-time setting which is stored in the database.  
Once you’ve set it every connection which opens the database automatically 
knows that it’s in WAL mode.

Set a timeout of at least thirty seconds.  You have to set this with every 
connection to the database (simplest to do it immediately after the 
sqlite3_open() command).

3. Leave locking mode to the default setting.

4. Use BEGIN without adding anything, which defaults to BEGIN DEFERRED.

I’m sure you’ve noticed a pattern here.  The default settings are pretty good 
for the way you want to use SQLite.  Try the above.  If you get a problem post 
again and we’ll try to figure out what to change.

> - Bulk INSERT or DELETE records, 10000 records per transaction (several 
> millions records total). 15% of requests.

Depending on how complicated your schema is, and the performance of your 
storage system, this may be a problem, an exception to the above.  If inserting 
10000 records in one transaction locks the database for too long, you might 
want to do them in batches of 1000, sleeping for a few milliseconds between 
blocks.  But it’s likely that you will have no problem with far longer blocks.

> Thanks for help and excuse me for bad English.

Always fun when people post this.  The people who think to post it write 
English better than I do.

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to