Try to open N separate database connections (without shared cache) and
load content using sqlite3_deserialize with
SQLITE_DESERIALIZE_READONLY flag.
http://www.sqlite.org/c3ref/deserialize.html
SQLite won't copy data but use provided buffer so you won't have N
copies of databse.

2018-05-13 12:50 GMT+02:00, Techno Magos :
> Hello
>
> I do not have clear examples to post  on this but would like to report
> findings around multi threaded read access (single process) in a large
> system that uses sqlite.
>
> This may be a known issue/restriction of memory sqlite behaviour, but
> wanted to check with the list first:
>
> 1. Running 2, 3, ... 6 multi threaded readers of a single *memory *sqlite
> database (via shared cache mode) on an 8 core cpu shows no throughput gain
> at all compared to single threaded throughput. In fact, it shows a
> throughput drop: i.e. if a single thread can do N simple queries/sec, 2
> threads .. up to 6 threads do a little less (10% drop) in total. This
> suggests that access to memory sqlite can only be serialized?
>
> 2. Running the same example on sqlite *file *(multi threaded mode; WAL
> journal) scales almost linearly;  so 6 threads provide nearly 6xN
> throughput. Single threaded throughput is a bit slower (around 15-20%)
> than single threaded in-memory access (expected).
>
> So, memory sqlite is not really usable with multiple threads (readers).
> While one might expect  that multiple readers of *memory *content could
> scale even better than with file content.
>
> Can this restriction be lifted?
> Is there some special mode possible to achieve scaling up throughput with
> multiple threads for memory sqlite content?
>
>
> Thanks
> _______________________________________________
> sqlite-users mailing list
> [email protected]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to