From 3468d06058a0ec792c9b54beb6da8c151004869b Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 8 May 2020 16:56:01 +0200 Subject: [PATCH] Query optimization --- app/src/main/java/eu/faircode/email/DaoMessage.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/DaoMessage.java b/app/src/main/java/eu/faircode/email/DaoMessage.java index 77b2534e10..2fa82fefb8 100644 --- a/app/src/main/java/eu/faircode/email/DaoMessage.java +++ b/app/src/main/java/eu/faircode/email/DaoMessage.java @@ -84,9 +84,9 @@ public interface DaoMessage { " OR (NOT :found AND :type IS NOT NULL AND ff.type = :type))" + " AND (NOT mm.ui_hide OR :debug))" + " GROUP BY account.id, CASE WHEN message.thread IS NULL OR NOT :threading THEN message.id ELSE message.thread END" + - " HAVING (SUM(:found AND message.ui_found) > 0" + // thread can be the same in different accounts - " OR SUM(NOT :found AND :type IS NULL AND folder.unified) > 0" + - " OR SUM(NOT :found AND :type IS NOT NULL AND folder.type = :type) > 0)" + + " HAVING (SUM((:found AND message.ui_found)" + + " OR (NOT :found AND :type IS NULL AND folder.unified)" + + " OR (NOT :found AND :type IS NOT NULL AND folder.type = :type)) > 0)" + // thread can be the same in different accounts " AND (NOT :filter_seen OR SUM(1 - message.ui_seen) > 0)" + " AND (NOT :filter_unflagged OR COUNT(message.id) - SUM(1 - message.ui_flagged) > 0)" + " AND (NOT :filter_unknown OR SUM(message.avatar IS NOT NULL AND message.sender <> identity.email) > 0)" +