I was wondering if it's possible to create an SQLite database where I can select
rows by rowid
with O(1).
I started using sqlite database in one of my projects and discovered that select
ing rows from bigger databased takes longer than select
ing rows from smaller databases. I started searching online and stumbled upon this article. Apparently, when select
ing by rowid
, instead of going straight to the rowid
, SQLite performs a binary search to get to the requested rowid
. This is a very logical solution, because we can delete rows from the database and in this case, going straight to the rowid
won't work.
But in my case - I have an "immutable" database, after creating the database I'm not changing it; Thus, all the rowid
are present and in the correct order.
So I was wandering if it's possible to either create a special database or use a specific query command which tells SQLite to select by accessing the rowid
without any binary search.
If there are other alternatives to SQLite that can perform better for my case please inform me about them (though, for in my project I can't load the db into memory and the access to different db's simultaneously should be instantaneous)
Thanks.