tags:

views:

16

answers:

1

I have a multi-threaded Linux C++ application that needs a high performance reference data lookup facility. I have been looking at using an in-memory SQLite database for this but can't see a way to get this to scale in my multi-threaded environment.

The default threading mode (serialized) seems to suffer from a single coarse grained lock even when all transactions are read only. Moreover, I don't believe I can use multi-thread mode because I can't create multiple connections to a single in-memory database (because every call to sqlite3_open(":memory:", &db) creates a separate in-memory database).

So what I want to know is: is there something I've missed in the documentation and it is possible to have multiple threads share access to the same in-memory database from my C++ application.

Alternatively, is there some alternative to SQLite that I could be considering ?

A: 

No, with SQLite you cannot access the same in-memory database from different threads. That's by design. More info at SQLite documentation.

xabriel
Given the page you reference is the only one in the documentation on in-memory databases, it's no surprise that I had already read it. It says nothing about not being able to access from multiple threads by design and in fact my application works just fine from multiple threads - it just doesn't scale as I add threads.
Fergus