Hi All,
I’m looking for an outside opinion. I’m developing a word game that uses a list of 200,000+ words. I’m trying to decide the best way to store and retrieve these words on the device. I’ve seen different examples but I’d like to better understand the trade-offs.
With my current implementation, I imported the words into a SQLite db. (As an aside – the text file I imported from is only 2.6MB, and my sqlite db was only 13KB. After the import my db is 14.8MB, almost 6 times the size of the file…is that normal??) When I go to validate the words, I put the list of all words played in a lua table and loop through it, querying the database with each word to see if it exists. I’ve noticed that on my phone this operation is seamless without any lag, but on the simulator (for Mac) there seems to be a slight bit of lag at that step. Could querying the db in rapid succession cause noticable lag on older phones?
The other method I’ve seen people use is just reading the file directly into a lua table and keeping all the words in memory. Of course, with this method I’m concerned about memory constraints on the device, but I think it would offer lightning fast lookups if I inserted every word as a key. Then I could just do something like below without having to worry about opening a connection to the db, performing multiple queries, then closing the db.
if(wordlist['word'] ~= nil) then --do stuff end
Also, I feel like doing it this way would help keep the size of the app bundle low. I don’t know if I messed up the SQLite import somehow, but a 6x increase seems crazy!
What are other people’s thoughts?