I have a table (rowID, name, familyName) with at least 100.000 rows (SQLite). I am using this code to query my table when the text of an EditText changes (onTextChanged):
mySelectSql = "Select rowID from gamtable WHERE name GLOB ' " + searchEditText.getText().toString() + "*';";
Cursor c1 = db.rawQuery(mySelectSql, null);
rowID is primary key, and name is indexed! This code runs slowly (~6000ms) just on the first key that entered in the EditText, and works fast and very fast on second, third, etc.
I need to improve my code to result in first entered key as fast as second and third one…
Any help on this issue?
Assuming it’s actually using an index (sounds like you’ve checked?), I would simply limit the number of results. Using the maximum number of displayable results in the UI preview.