Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it better to use an in-memory database (e.g. SQLite) than to keep everything in HashMap or other data structures?

I need to have very fast access to a big Map - several millions of entries. Is it worth using an SQLite in-memory database to keep that map as opposed to just having that HashMap in memory?

like image 663
Fixpoint Avatar asked Sep 11 '25 02:09

Fixpoint


1 Answers

its depends on the services you require from your data structure. do you only need to retrieve values from the map? or do you need to do a complex query or sorting?.

there is nothing magical about a database internal structure, to make it arbitrary faster then a simple data structure . In the database there are more facilities to manipulate large sets of data that probably will cost in an overheard of CPU and memory. if you only need a dictionary like functionality , go with a map, for something more complex consider a database

like image 127
Alon Avatar answered Sep 13 '25 15:09

Alon