Strange idea: SQLite's RAM memory clone

peacemaker

Expert
Licensed User
Longtime User
Hi, All

I have found that my app speed is lower than needed.
It uses rather complex data structure and SQLite helps very much: several static dictionary tables and the online-realtime working data table.
But SQLite file db depends on the drive, SSD or HDD speed., as i can understand.

So, strange idea: maybe is there SQLite-like engine working ... only in RAM ? Reading from drive the initial data, but some tables are marked as existing only in RAM...
Crazy ?
 

JohnJ

Member
Licensed User
Longtime User
Hi, All

I have found that my app speed is lower than needed.
It uses rather complex data structure and SQLite helps very much: several static dictionary tables and the online-realtime working data table.
But SQLite file db depends on the drive, SSD or HDD speed., as i can understand.

So, strange idea: maybe is there SQLite-like engine working ... only in RAM ? Reading from drive the initial data, but some tables are marked as existing only in RAM...
Crazy ?
Yes, google sqlite in-memory tables
 

peacemaker

Expert
Licensed User
Longtime User
A better solution:
1. Analyze your queries and add indices when needed.
2. Use the async methods.
It's measuring app, reading data from COM-ports, serial sequencies can be very fast, so, max saving speed is needed anyway.
 

incendio

Well-Known Member
Licensed User
Longtime User
Been using sqlite in memory since use B4A for the first time.

Used it for temporary file so don't need to do clean up when app closed.

Never compared speed with db in file, but sometimes need thousand of records to process, db in memory served well for this purpose.

Also with db in memory, you have global data that can be accessed from all activities / pages.
 

tchart

Well-Known Member
Licensed User
Longtime User
Wow ! But how to use in B4J ?

SOLVED:

Seems, the topic can be moved into Question forum.

Does this "memory" SQLite work in Android also ?
I wrote some code somewhere that will copy an entire SQLite db into an in memory a SQLite database. Will see if I can dig it up. From my experiments it did not give me any significant performance gains.

However as Erel said you probably need to give your DB some TLC. I find with larger databases you need to optimize, flush the WAL and rebuild indexes. I do this after large operations and also on start up of my app. This will greatly improves performance.
 

tchart

Well-Known Member
Licensed User
Longtime User
Ive posted my project that clones a database to "in memory" here;

 

peacemaker

Expert
Licensed User
Longtime User
Ive posted my project that clones a database to "in memory" here;

Thanks. Actually, now i'm using 2 dbs - one for realtime processing in RAM only, an second for storing constant records in a file.
All is OK, including Android, as Windows. But not sure yet how will be if the app is to be working for looooong time. I guess, soon some error about OutOfMemory may occur...
 

KMatle

Expert
Licensed User
Longtime User
Mostly a design "issue". Direct access with a good structure and good indexes should be fine. Usage of in memory db's is fine (I use it more to spare my drive a bit when the data is static and used a lot). The rest depends on the data. Big data is a server task. Apps should only show some data (the results) and not do big data jobs.
 
Top