4

I have a 7GB SQLite file and I am running multiple queries on it from different virtual machines in the cloud. Some of the queries are running in Python using the built in sqlite3 package, and others originate from SQL queries running in DB Visualizer. The file itself is on a network share (and for policy reasons cannot be copied locally).

Will these concurrent queries slow each other down?

I could copy the SQLite file multiple times on the network share and connect each concurrent query to its own copy of the file. Would that speed things up?

I can imagine that both the sqlite3 Python driver and DBVisualizer copy the database file into local temporary storage first (or into memory) in which case there is no speed-up to be gained, or they don't.

1 Answer 1

9

Concurrency is not a problem, as long as you only read. SQLite doesn't allow concurrency on writes, because it never was designed for that. I don't know the internals of the python driver and DBVisualized, but expect both smb, your os and any middleware to cache automatically at least parts of the file, because unless requested so, it is done automatically to speed up filesystem access. Details would depend on os configuration and access details.

I would like to comment on something you didn't ask about, which is the fit of your architecture:

  • You need to access a database over the network
  • You need to have certain level of concurrency
  • You need to control access, because policy reasons (and probably some of those policy reasons could be backups)
  • You have expectations about performance
  • You need to control in a more fine-grained way what is on memory and what is on disk
  • Your database has grown beyond a trivial size

(and those are only the ones that are perceived from your question)

SQLite is a great piece of software, but please consider if it is the right technology for you, as this is almost a paradigmatic case of when not to use it. Sure, you can create a loop device and copy it in memory, and you may get some improvements, but you could also migrate to a distributed system with an integrated cache system (like any other multi-user relational database) and let the technology solve all this issues for you.

Accessing sqlite using a network share is really a hack, and network filesystems are known to have caused data loss due to its limitations towards write consistency.

2
  • Thanks, it is only me accessing the raw database itself. My scripts produce CSV files and our data scientists and machine learning researchers process and ingest the CSV files. So it's not as distributed as it sounds, though since the queries I run are long-running, it is very useful for me to run them concurrently.
    – dumbledad
    Apr 10, 2019 at 14:47
  • "process and ingest the CSV files" -> s/multi-user relational database/Hadoop/. Researchers and data scientists love map reduce! :-D Sure, it is a more complex setup, so I get it, but I am not sure if more than the headaches that SMB will give you in the long term...
    – jynus
    Apr 10, 2019 at 14:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.