From 7b55691ceebc4cf45bc87e0db3268c7f27d46104 Mon Sep 17 00:00:00 2001 From: Mark Hahnenberg Date: Tue, 21 Feb 2017 16:23:07 -0800 Subject: [PATCH] [client-app] Don't compute thread search index size on startup Summary: We did this to see if we should clear the index, which no longer makes sense because the index never exceeds our threshold. Additionally, none of the other search indexes do this. This was causing us to spend a ton of time scanning the ThreadSearch table at startup. Test Plan: Run locally, make sure things are fine Reviewers: evan, spang, juan Reviewed By: juan Differential Revision: https://phab.nylas.com/D4007 --- .../search-index/lib/thread-search-index-store.es6 | 10 +--------- packages/client-app/src/flux/stores/database-store.es6 | 6 ------ 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/packages/client-app/internal_packages/search-index/lib/thread-search-index-store.es6 b/packages/client-app/internal_packages/search-index/lib/thread-search-index-store.es6 index 4aa0d4ee6..c48c18477 100644 --- a/packages/client-app/internal_packages/search-index/lib/thread-search-index-store.es6 +++ b/packages/client-app/internal_packages/search-index/lib/thread-search-index-store.es6 @@ -64,15 +64,7 @@ class ThreadSearchIndexStore { .then(() => this.buildIndex(this.accountIds)) } - return DatabaseStore.searchIndexSize(Thread) - .then((size) => { - console.log(`Thread Search: Current index size is ${(size || 0)} threads`) - if (this._isInvalidSize(size)) { - return this.clearIndex().thenReturn(this.accountIds) - } - return this.getUnindexedAccounts() - }) - .then((accountIds) => this.buildIndex(accountIds)) + return this.getUnindexedAccounts().then((accountIds) => this.buildIndex(accountIds)); } /** diff --git a/packages/client-app/src/flux/stores/database-store.es6 b/packages/client-app/src/flux/stores/database-store.es6 index 4093db485..fff54ae60 100644 --- a/packages/client-app/src/flux/stores/database-store.es6 +++ b/packages/client-app/src/flux/stores/database-store.es6 @@ -729,12 +729,6 @@ class DatabaseStore extends NylasStore { return this._query(sql); } - searchIndexSize(klass) { - const searchTableName = `${klass.name}Search`; - const sql = `SELECT COUNT(content_id) as count FROM \`${searchTableName}\``; - return this._query(sql).then((result) => result[0].count); - } - isIndexEmptyForAccount(accountId, modelKlass) { const modelTable = modelKlass.name const sql = (