In my Android app, I need to get 50,000 database entries (text) and compare them with a value when the activity starts (in onCreate()). I am doing this with the simplest way: I get the whole table from db to a cursor. However this way is too laggy. Are there any other ways to do it more effectively ?
Edit: The app is “scrabble solver” that is why I am not using WHERE clause in my query (Take the whole data and compare it with combination of the input letters). At first I was using a big table which contains whole possible words. Now I am using 26 tables. This reduced the lag and I am making database calls on a thread – that solved a lot problems too. It is still little bit laggy but much better.
To summarize and add a bit more
EXPLAIN QUERY PLANhttp://www.sqlite.org/lang_explain.html and look for anyscanoperations, these are much slower thansearchoperations. Uses indexes to avoidscanoperations.onCreate(), always use anAsyncTask, aHandlerrunning on a background thread or some other non-main thread.