mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-09-12 23:54:45 +08:00
perf(db): Use same subselect for "related emails" queries
This commit is contained in:
parent
c5f4c7305d
commit
9a2af44b5f
2 changed files with 8 additions and 2 deletions
|
@ -289,7 +289,8 @@ class ModelQuery
|
||||||
#
|
#
|
||||||
_canSubselectForJoin: (matcher) ->
|
_canSubselectForJoin: (matcher) ->
|
||||||
joinAttribute = matcher.attribute()
|
joinAttribute = matcher.attribute()
|
||||||
return false unless joinAttribute.joinOnField is 'id'
|
|
||||||
|
return unless @_range.limit?
|
||||||
|
|
||||||
allMatchersOnJoinTable = _.every @_matchers, (m) ->
|
allMatchersOnJoinTable = _.every @_matchers, (m) ->
|
||||||
m is matcher or joinAttribute.joinQueryableBy.indexOf(m.attr.modelKey) isnt -1
|
m is matcher or joinAttribute.joinQueryableBy.indexOf(m.attr.modelKey) isnt -1
|
||||||
|
|
|
@ -80,6 +80,7 @@ class Thread extends ModelWithMetadata {
|
||||||
queryable: true,
|
queryable: true,
|
||||||
joinOnField: 'email',
|
joinOnField: 'email',
|
||||||
modelKey: 'participants',
|
modelKey: 'participants',
|
||||||
|
joinQueryableBy: ['lastMessageReceivedTimestamp'],
|
||||||
itemClass: Contact,
|
itemClass: Contact,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
@ -115,9 +116,13 @@ class Thread extends ModelWithMetadata {
|
||||||
'CREATE TABLE IF NOT EXISTS `ThreadCounts` (`category_id` TEXT PRIMARY KEY, `unread` INTEGER, `total` INTEGER)',
|
'CREATE TABLE IF NOT EXISTS `ThreadCounts` (`category_id` TEXT PRIMARY KEY, `unread` INTEGER, `total` INTEGER)',
|
||||||
'CREATE UNIQUE INDEX IF NOT EXISTS ThreadCountsIndex ON `ThreadCounts` (category_id DESC)',
|
'CREATE UNIQUE INDEX IF NOT EXISTS ThreadCountsIndex ON `ThreadCounts` (category_id DESC)',
|
||||||
|
|
||||||
|
'CREATE INDEX IF NOT EXISTS ThreadContactDateIndex ON `ThreadContact`(last_message_received_timestamp DESC, value, id)',
|
||||||
|
|
||||||
|
'CREATE INDEX IF NOT EXISTS ThreadDateIndex ON `Thread`(last_message_received_timestamp DESC, id)',
|
||||||
|
'CREATE INDEX IF NOT EXISTS ThreadStarIndex ON Thread(account_id, starred)',
|
||||||
|
|
||||||
'CREATE INDEX IF NOT EXISTS ThreadListCategoryIndex ON `ThreadCategory`(last_message_received_timestamp DESC, value, in_all_mail, unread, id)',
|
'CREATE INDEX IF NOT EXISTS ThreadListCategoryIndex ON `ThreadCategory`(last_message_received_timestamp DESC, value, in_all_mail, unread, id)',
|
||||||
'CREATE INDEX IF NOT EXISTS ThreadListCategorySentIndex ON `ThreadCategory`(last_message_sent_timestamp DESC, value, in_all_mail, unread, id)',
|
'CREATE INDEX IF NOT EXISTS ThreadListCategorySentIndex ON `ThreadCategory`(last_message_sent_timestamp DESC, value, in_all_mail, unread, id)',
|
||||||
'CREATE INDEX IF NOT EXISTS ThreadStarIndex ON Thread(account_id, starred)',
|
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue