Mailspring/spec
Ben Gotow b75ed6f920 perf(db): Use subselect to improve thread list query perf (53%!)
Summary:
- Use a sub-select query with much better performance to display the thread list
- Perform analyze on tables after launch

The new query is:

```
SELECT `Thread`.`data` FROM `Thread` WHERE `Thread`.`id` IN (SELECT `id` FROM `ThreadCategory` AS `M26` WHERE `M26`.`value` IN ('9m9ks71k06n5rmx82kgues09p','9s9k25q6j1krjgpkovbcjm7d','13b7ufruoymvih07ki0uahlto','dtmhlzz6phr47zp512knhjgf8','16dvjb84bszfh15kgfrjj37i3','aclwmgncdqjfibp51bvgbeik','17qad7jhbp6tozog3klm5zagt','4x4bkbawiq825u4eu3aus8tll','7axr9f5f1lzpwm2rw2ghkirhq','dsnn660af0pmou2gg3nstga8a','361qr5rva1ieby2r0ec3sn0bm','10fyvba7pjyjgeyr5i65i1zri') AND `M26`.`in_all_mail` = 1  ORDER BY `M26`.`last_message_received_timestamp` DESC LIMIT 200 OFFSET 0) ORDER BY `Thread`.`last_message_received_timestamp` DESC;
`
0|0|0|SEARCH TABLE Thread USING INDEX Thread_id (id=?)
0|0|0|EXECUTE LIST SUBQUERY 1
1|0|0|SCAN TABLE Thread-Category AS M26 USING COVERING INDEX ThreadFancyIndex
1|0|0|EXECUTE LIST SUBQUERY 2
0|0|0|USE TEMP B-TREE FOR (only on 200 result items)
```

Which is twice as performant as:
```
SELECT `Thread`.`data` FROM `Thread` INNER JOIN `ThreadCategory` AS `M26` ON `M26`.`id` = `Thread`.`id` WHERE `M26`.`value` IN ('9m9ks71k06n5rmx82kgues09p','9s9k25q6j1krjgpkovbcjm7d','13b7ufruoymvih07ki0uahlto','dtmhlzz6phr47zp512knhjgf8','16dvjb84bszfh15kgfrjj37i3','aclwmgncdqjfibp51bvgbeik','17qad7jhbp6tozog3klm5zagt','4x4bkbawiq825u4eu3aus8tll','7axr9f5f1lzpwm2rw2ghkirhq','361qr5rva1ieby2r0ec3sn0bm','10fyvba7pjyjgeyr5i65i1zri') AND `M26`.`in_all_mail` = 1  ORDER BY `M26`.`last_message_received_timestamp` DESC LIMIT 200 OFFSET 0;

0|0|1|SCAN TABLE Thread-Category AS M26 USING COVERING INDEX ThreadFancyIndex
0|0|0|EXECUTE LIST SUBQUERY 1
0|1|0|SEARCH TABLE Thread USING INDEX Thread_id (id=?)
```

Test Plan: Broken!

Reviewers: evan, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D2869
2016-04-11 13:29:05 -07:00
..
components fix(focus): Remove focusedField in favor of imperative focus, break apart ComposerView 2016-04-04 15:22:01 -07:00
extensions fix(quick-schedule): Update to use new APIs, remove leftover docs 2016-03-18 10:43:43 -07:00
fixtures perf(db): Use subselect to improve thread list query perf (53%!) 2016-04-11 13:29:05 -07:00
models fix(db-spec): Accompanying spec changes 2016-04-05 19:03:47 -07:00
services feat(paste): Paste accepts more HTML, paste and match style now available 2015-12-07 15:34:03 -08:00
stores perf(db): Use subselect to improve thread list query perf (53%!) 2016-04-11 13:29:05 -07:00
tasks fix(spec): fix bad ref 2016-04-09 22:07:50 -04:00
action-bridge-spec.coffee refactor(env): new NylasEnv global 2015-11-17 16:41:20 -08:00
auto-update-manager-spec.coffee bump(electron): 0.34.3 => 0.35.1 2015-11-23 22:09:17 -08:00
buffered-process-spec.coffee refactor(spec) move spec-nylas to spec 2015-10-01 21:39:44 -07:00
clipboard-spec.coffee refactor(env): new NylasEnv global 2015-11-17 16:41:20 -08:00
component-registry-spec.coffee refactor(spec) move spec-nylas to spec 2015-10-01 21:39:44 -07:00
database-object-registry-spec.coffee refactor(spec) move spec-nylas to spec 2015-10-01 21:39:44 -07:00
date-utils-spec.es6 fix(date-utils): Add localization to date formats 2016-03-07 16:44:54 -08:00
dom-utils-spec.coffee refactor(spec) move spec-nylas to spec 2015-10-01 21:39:44 -07:00
extension-registry-spec.coffee update(extensions): Rename DraftStoreExtension and MessageStoreExtension 2015-11-30 16:08:05 -08:00
jasmine-helper.coffee refactor(spec): remove spectron from main app 2015-12-02 13:42:09 -08:00
jasmine-jquery.js refactor(dir): move exports to src/global and consolidate tests 2015-10-02 09:19:37 -07:00
jasmine.js refactor(dir): move exports to src/global and consolidate tests 2015-10-02 09:19:37 -07:00
launch-services-spec.coffee refactor(spec) move spec-nylas to spec 2015-10-01 21:39:44 -07:00
list-selection-spec.coffee feat(outbox): Sending status now appears beside drafts 2016-02-04 14:14:24 -08:00
mail-rules-processor-spec.coffee fix(mail-rules): Catch and disable mail rules building bad actions 2015-12-28 18:39:06 -08:00
mailbox-perspective-spec.es6 feat(thread-search): Add spinner to indicate search in progress 2016-04-10 16:20:26 -07:00
menu-manager-spec.coffee refactor(env): new NylasEnv global 2015-11-17 16:41:20 -08:00
module-cache-spec.coffee fix(specs): Update specs following 0.29.2 > 0.34.3 move 2015-11-17 17:40:06 -08:00
n1-spec-reporter.coffee 🎨: Smaller buttons, smaller toolbar, smaller text 2016-02-09 19:45:24 -08:00
nylas-api-spec.coffee fix(specs): * 2016-04-08 16:03:21 -07:00
nylas-env-spec.coffee refactor(env): new NylasEnv global 2015-11-17 16:41:20 -08:00
nylas-protocol-handler-spec.coffee fix(specs): Update specs following 0.29.2 > 0.34.3 move 2015-11-17 17:40:06 -08:00
nylas-test-utils.coffee bump(react): 0.13.2 => 0.14.7 2016-03-29 01:43:12 -07:00
package-manager-spec.coffee refactor(env): new NylasEnv global 2015-11-17 16:41:20 -08:00
package-spec.coffee refactor(env): new NylasEnv global 2015-11-17 16:41:20 -08:00
quoted-html-transformer-spec.coffee feat(quote): add new quoted text detector for quote strings 2016-03-03 17:30:36 -08:00
quoted-plain-text-transformer-spec.coffee feat(paste): Paste accepts more HTML, paste and match style now available 2015-12-07 15:34:03 -08:00
spec-bootstrap.coffee bump(*): Electron 0.36.7, version to 0.4.6 2016-02-08 18:35:23 -08:00
spec-helper-platform.coffee fix(drafts): Various improvements and fixes to drafts, draft state management 2015-02-03 16:24:31 -08:00
spec-helper.coffee bump(react): 0.13.2 => 0.14.7 2016-03-29 01:43:12 -07:00
spec-suite.coffee refactor(env): new NylasEnv global 2015-11-17 16:41:20 -08:00
spellchecker-spec.coffee fix(spellcheck): let win < 8 fallback to hunspell 2015-12-11 16:41:41 -05:00
style-manager-spec.coffee refactor(spec) move spec-nylas to spec 2015-10-01 21:39:44 -07:00
styles-element-spec.coffee refactor(env): new NylasEnv global 2015-11-17 16:41:20 -08:00
task-factory-spec.es6 fix(remove-from-view): Fix logic for delete/remove-from-view behavior: 2016-03-07 18:16:37 -08:00
theme-manager-spec.coffee feat(tasks): add Create, Update, Destroy tasks plus spec & lint fixes 2016-01-15 15:16:21 -05:00
time-override.coffee feat(tests): add integration tests 2015-12-02 13:41:14 -08:00
time-reporter.coffee refactor(utils): switch to regular underscore 2015-05-19 16:06:59 -07:00
undo-manager-spec.coffee fix(composer): support Chinese & others - handle composition events 2015-10-30 20:03:33 -04:00
utils-spec.coffee fix(trash/spam): New inAllMail filter applied to all mailbox views except trash and spam 2016-03-10 12:41:32 -08:00