mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-01 12:44:42 +00:00
Folder query optimizations
This commit is contained in:
parent
499a82fbb9
commit
adccd0a4a3
1 changed files with 12 additions and 12 deletions
|
@ -38,13 +38,13 @@ public interface DaoFolder {
|
|||
", account.id AS accountId, account.pop AS accountProtocol, account.`order` AS accountOrder" +
|
||||
", account.name AS accountName, account.state AS accountState" +
|
||||
", COUNT(DISTINCT CASE WHEN rule.enabled THEN rule.id ELSE NULL END) rules" +
|
||||
", COUNT(DISTINCT CASE WHEN message.ui_hide THEN NULL ELSE message.id END) AS messages" +
|
||||
", COUNT(DISTINCT CASE WHEN message.content = 1 AND NOT message.ui_hide THEN message.id ELSE NULL END) AS content" +
|
||||
", COUNT(DISTINCT CASE WHEN NOT message.ui_seen AND NOT message.ui_hide THEN message.id ELSE NULL END) AS unseen" +
|
||||
", COUNT(DISTINCT message.id) AS messages" +
|
||||
", COUNT(DISTINCT CASE WHEN message.content = 1 THEN message.id ELSE NULL END) AS content" +
|
||||
", COUNT(DISTINCT CASE WHEN NOT message.ui_seen THEN message.id ELSE NULL END) AS unseen" +
|
||||
", COUNT(DISTINCT CASE WHEN operation.state = 'executing' THEN operation.id ELSE NULL END) AS executing" +
|
||||
" FROM folder" +
|
||||
" LEFT JOIN account ON account.id = folder.account" +
|
||||
" LEFT JOIN message ON message.folder = folder.id" +
|
||||
" LEFT JOIN message ON message.folder = folder.id AND NOT message.ui_hide" +
|
||||
" LEFT JOIN rule ON rule.folder = folder.id" +
|
||||
" LEFT JOIN operation ON operation.folder = folder.id" +
|
||||
" WHERE folder.account = :account AND account.synchronize" +
|
||||
|
@ -97,13 +97,13 @@ public interface DaoFolder {
|
|||
", account.id AS accountId, account.pop AS accountProtocol, account.`order` AS accountOrder" +
|
||||
", account.name AS accountName, account.state AS accountState" +
|
||||
", COUNT(DISTINCT CASE WHEN rule.enabled THEN rule.id ELSE NULL END) rules" +
|
||||
", COUNT(DISTINCT CASE WHEN message.ui_hide THEN NULL ELSE message.id END) AS messages" +
|
||||
", COUNT(DISTINCT CASE WHEN message.content = 1 AND NOT message.ui_hide THEN message.id ELSE NULL END) AS content" +
|
||||
", COUNT(DISTINCT CASE WHEN NOT message.ui_seen AND NOT message.ui_hide THEN message.id ELSE NULL END) AS unseen" +
|
||||
", COUNT(DISTINCT message.id) AS messages" +
|
||||
", COUNT(DISTINCT CASE WHEN message.content = 1 THEN message.id ELSE NULL END) AS content" +
|
||||
", COUNT(DISTINCT CASE WHEN NOT message.ui_seen THEN message.id ELSE NULL END) AS unseen" +
|
||||
", COUNT(DISTINCT CASE WHEN operation.state = 'executing' THEN operation.id ELSE NULL END) AS executing" +
|
||||
" FROM folder" +
|
||||
" JOIN account ON account.id = folder.account" +
|
||||
" LEFT JOIN message ON message.folder = folder.id" +
|
||||
" LEFT JOIN message ON message.folder = folder.id AND NOT message.ui_hide" +
|
||||
" LEFT JOIN rule ON rule.folder = folder.id" +
|
||||
" LEFT JOIN operation ON operation.folder = folder.id" +
|
||||
" WHERE account.`synchronize`" +
|
||||
|
@ -134,13 +134,13 @@ public interface DaoFolder {
|
|||
", account.id AS accountId, account.pop AS accountProtocol, account.`order` AS accountOrder" +
|
||||
", account.name AS accountName, account.state AS accountState" +
|
||||
", COUNT(DISTINCT CASE WHEN rule.enabled THEN rule.id ELSE NULL END) rules" +
|
||||
", COUNT(DISTINCT CASE WHEN message.ui_hide THEN NULL ELSE message.id END) AS messages" +
|
||||
", COUNT(DISTINCT CASE WHEN message.content = 1 AND NOT message.ui_hide THEN message.id ELSE NULL END) AS content" +
|
||||
", COUNT(DISTINCT CASE WHEN NOT message.ui_seen AND NOT message.ui_hide THEN message.id ELSE NULL END) AS unseen" +
|
||||
", COUNT(DISTINCT message.id) AS messages" +
|
||||
", COUNT(DISTINCT CASE WHEN message.content = 1 THEN message.id ELSE NULL END) AS content" +
|
||||
", COUNT(DISTINCT CASE WHEN NOT message.ui_seen THEN message.id ELSE NULL END) AS unseen" +
|
||||
", COUNT(DISTINCT CASE WHEN operation.state = 'executing' THEN operation.id ELSE NULL END) AS executing" +
|
||||
" FROM folder" +
|
||||
" LEFT JOIN account ON account.id = folder.account" +
|
||||
" LEFT JOIN message ON message.folder = folder.id" +
|
||||
" LEFT JOIN message ON message.folder = folder.id AND NOT message.ui_hide" +
|
||||
" LEFT JOIN rule ON rule.folder = folder.id" +
|
||||
" LEFT JOIN operation ON operation.folder = folder.id" +
|
||||
" WHERE folder.id = :id" +
|
||||
|
|
Loading…
Reference in a new issue