mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-11 18:32:20 +08:00
Disable SELECT DISTINCT unless we know we need it
This commit is contained in:
parent
ffb5e0dfda
commit
a3b1f77d45
1 changed files with 6 additions and 1 deletions
|
@ -181,7 +181,12 @@ class CategoryMailboxPerspective extends MailboxPerspective
|
|||
.where([Thread.attributes.categories.containsAny(_.pluck(@categories(), 'id'))])
|
||||
.limit(0)
|
||||
|
||||
query.distinct() if @categories().length > 1
|
||||
if @_categories.length > 1 and @accountIds.length < @_categories.length
|
||||
# The user has multiple categories in the same account selected, which
|
||||
# means our result set could contain multiple copies of the same threads
|
||||
# (since we do an inner join) and we need SELECT DISTINCT. Note that this
|
||||
# can be /much/ slower and we shouldn't do it if we know we don't need it.
|
||||
query.distinct()
|
||||
|
||||
return new MutableQuerySubscription(query, {asResultSet: true})
|
||||
|
||||
|
|
Loading…
Reference in a new issue