Is there an effective way to speed up an Android database query?

In my Android application, I need to get 50,000 records in the database (text) and compare them with the value when the action (c onCreate()) begins . I do this in the simplest way: I get the whole table from db to cursor. However, this path is too backward. Are there other ways to do this more efficiently?

Edit: The application is a "scrabble solver", so I do not use the sentence WHEREin my query (take all the data and compare it with a combination of input letters). At first I used a large table containing entire possible words. Now I use 26 tables. This has reduced latency, and I am making database calls in a stream, which also solves a lot of problems. This is still a bit laggy, but much better.

+5
source share
4 answers

To summarize and add a little more

+9
+2

WHERE SQL, . WHERE.

+1
source

At the very least, you can put the index in the field you are comparing and use a sentence WHERE. If you compare numerical values, Sqlite (the db engine used by Android) supports features like MINand MAX. Also, if you are comparing partial strings, you can use LIKE. There are many resources for optimizing queries such as this.

+1
source

All Articles