Browse Source

Speed up the retrieval of search suggestions from the database.

Since the maximum amount of displayed suggestions is set at 5, it makes
sense to limit the query to a maximum of 5. This speeds up the query
significantly which makes queries more responsive.
master
Anthony Restaino 10 years ago
parent
commit
73b367053c
  1. 4
      src/acr/browser/lightning/HistoryDatabaseHandler.java

4
src/acr/browser/lightning/HistoryDatabaseHandler.java

@ -115,7 +115,7 @@ public class HistoryDatabaseHandler extends SQLiteOpenHelper {
List<HistoryItem> itemList = new ArrayList<HistoryItem>(); List<HistoryItem> itemList = new ArrayList<HistoryItem>();
// select query // select query
String selectQuery = "SELECT * FROM " + TABLE_HISTORY + " WHERE " + KEY_TITLE + " LIKE '%" String selectQuery = "SELECT * FROM " + TABLE_HISTORY + " WHERE " + KEY_TITLE + " LIKE '%"
+ search + "%' OR " + KEY_URL + " LIKE '%" + search + "%'"; + search + "%' OR " + KEY_URL + " LIKE '%" + search + "%' LIMIT 5";
Cursor cursor = mDatabase.rawQuery(selectQuery, null); Cursor cursor = mDatabase.rawQuery(selectQuery, null);
// looping through all rows and adding to list // looping through all rows and adding to list
@ -139,7 +139,7 @@ public class HistoryDatabaseHandler extends SQLiteOpenHelper {
public List<HistoryItem> getLastHundredItems() { public List<HistoryItem> getLastHundredItems() {
List<HistoryItem> itemList = new ArrayList<HistoryItem>(); List<HistoryItem> itemList = new ArrayList<HistoryItem>();
String selectQuery = "SELECT * FROM " + TABLE_HISTORY; String selectQuery = "SELECT * FROM " + TABLE_HISTORY;
Cursor cursor = mDatabase.rawQuery(selectQuery, null); Cursor cursor = mDatabase.rawQuery(selectQuery, null);
int counter = 0; int counter = 0;

Loading…
Cancel
Save