Remove indexes which used accountId as the first param... not faster

This commit is contained in:
Ben Gotow 2016-01-28 10:03:21 -08:00
parent 1e6b857437
commit 4edbe7652c
4 changed files with 4 additions and 6 deletions

View file

@ -158,8 +158,7 @@ class Message extends Model
@additionalSQLiteConfig:
setup: ->
['CREATE INDEX IF NOT EXISTS MessageListIndex ON Message(account_id, thread_id, date ASC)',
'CREATE INDEX IF NOT EXISTS MessageListThreadIndex ON Message(thread_id, date ASC)',
['CREATE INDEX IF NOT EXISTS MessageListThreadIndex ON Message(thread_id, date ASC)',
'CREATE INDEX IF NOT EXISTS MessageListDraftIndex ON Message(account_id, draft)',
'CREATE UNIQUE INDEX IF NOT EXISTS MessageDraftIndex ON Message(client_id)',
'CREATE UNIQUE INDEX IF NOT EXISTS MessageBodyIndex ON MessageBody(id)']

View file

@ -100,7 +100,7 @@ class Thread extends Model
@additionalSQLiteConfig:
setup: ->
['CREATE INDEX IF NOT EXISTS ThreadListIndex ON Thread(account_id, last_message_received_timestamp DESC, id)']
['CREATE INDEX IF NOT EXISTS ThreadListIndex ON Thread(last_message_received_timestamp DESC, id)']
fromJSON: (json) ->
super(json)

View file

@ -211,7 +211,7 @@ class MessageStore extends NylasStore
loadedThreadId = @_thread.id
query = DatabaseStore.findAll(Message)
query.where(threadId: loadedThreadId, accountId: @_thread.accountId)
query.where(threadId: loadedThreadId)
query.include(Message.attributes.body)
query.then (items) =>
# Check to make sure that our thread is still the thread we were

View file

@ -198,8 +198,7 @@ class CategoryMailboxPerspective extends MailboxPerspective
super(other) and _.isEqual(@categories(), other.categories())
threads: =>
query = DatabaseStore
.findAll(Thread)
query = DatabaseStore.findAll(Thread)
.where([Thread.attributes.categories.containsAny(_.pluck(@categories(), 'id'))])
.limit(0)