Improved search performance

This commit is contained in:
M66B
2019-10-23 20:01:43 +02:00
parent 0d25268240
commit 1772530ae6
5 changed files with 61 additions and 28 deletions

View File

@@ -212,6 +212,19 @@ public interface DaoMessage {
List<Long> getMessageByFolder(long folder);
@Query("SELECT id" +
" FROM message" +
" WHERE (:folder IS NULL OR folder = :folder)" +
" AND NOT ui_hide" +
" ORDER BY message.received DESC")
List<Long> getMessageIdsByFolder(Long folder);
@Query("SELECT id, account, thread, (:find IS NULL" +
" OR `from` LIKE :find COLLATE NOCASE" +
" OR `to` LIKE :find COLLATE NOCASE" +
" OR `cc` LIKE :find COLLATE NOCASE" +
" OR `subject` LIKE :find COLLATE NOCASE" +
" OR `keywords` LIKE :find COLLATE NOCASE" +
" OR `preview` LIKE :find COLLATE NOCASE) AS matched" +
" FROM message" +
" WHERE (:folder IS NULL OR folder = :folder)" +
" AND NOT ui_hide" +
@@ -222,7 +235,7 @@ public interface DaoMessage {
" WHEN 1 THEN message.ui_snoozed IS NOT NULL" +
" ELSE 1 END" + // NULL: true
" ORDER BY message.received DESC")
List<Long> getMessageIdsByFolder(Long folder, Boolean seen, Boolean flagged, Boolean snoozed);
List<TupleMatch> matchMessages(Long folder, String find, Boolean seen, Boolean flagged, Boolean snoozed);
@Query("SELECT id" +
" FROM message" +
@@ -364,16 +377,6 @@ public interface DaoMessage {
" ORDER BY sender, subject")
Cursor getSuggestions(String query);
@Query("SELECT * FROM message" +
" WHERE id = :id" +
" AND (`from` LIKE :find COLLATE NOCASE" +
" OR `to` LIKE :find COLLATE NOCASE" +
" OR `cc` LIKE :find COLLATE NOCASE" +
" OR `subject` LIKE :find COLLATE NOCASE" +
" OR `keywords` LIKE :find COLLATE NOCASE" +
" OR `preview` LIKE :find COLLATE NOCASE)")
EntityMessage match(long id, String find);
@Insert
long insertMessage(EntityMessage message);