palantir/sqlite3worker

Feature Request: Do not queue SELECT queries if no writing is happening.

Opened this issue · 1 comments

First of all, I may be mistaken in how this all works, but it seems like all queries are queued and processed serially. Since there is already a conditional for if using a "SELECT ...", why not execute them directly?

Or, am I mistaken and you can't read from a database while locked (obviously you can't write). If that is the case, you could check the queue size and then execute in parallel.

It started this way. There are some weird async issues when selects were just performed and returned. So to fix it we put selects in the same serialization as write operations.

If there is 0 in the queue size then the select will execute immediately since the blocking queue get while unblock and execute. I'm not sure what the added latency is for this but it is probably negligible.

This could be cleaned up by putting the queue put in execute outside the if block since it's not the actual choice but if you wait to return results is.