I'm writing a python program which accesses two different SQLITE3 databases in two different python threads. Am I right in thinking that this will use 2 cores on my machine?
Asked
Active
Viewed 133 times
0
-
Are you reading or writing? SQLite only supports one writer at a time, so no matter what you or Python does, if you're trying to improve write speed by multithreading, it won't help. – Colonel Thirty Two Sep 13 '15 at 17:59
-
even in different databases ? Does that count for different processes too? – Well3 Sep 13 '15 at 20:35
-
The lock is per database, and counts for other processes too. – Colonel Thirty Two Sep 14 '15 at 11:51
1 Answers
0
This reply implies that the pysqlite module releases the GIL while calling the C-language sqlite API. So both cores must be used efficiently. What happens when the result sets are processed by Python is another matter, and there can be a slow-down related to the global interpreter lock. In the case of relatively fast SQL queries, using processes instead of threads could be a bit faster. (I did not check the pysqlite source code myself).

Community
- 1
- 1

Mike Bessonov
- 676
- 3
- 8