Mailspring/spec/stores
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
..
account-store-spec.coffee perf(autolinker): Use requestIdleCallback to fix hanging on large bodies 2016-03-23 19:03:21 -07:00
badge-store-spec.coffee fix(tray): Use total count, not unread count, for tray icon 2016-03-21 17:36:18 -07:00
category-store-spec.es6 fix(snooze): Correctly query and create snooze categories per account 2016-03-14 15:36:39 -07:00
contact-store-spec.coffee fix(contact-search): Keep only ranked contacts, query for others. Massive perf boost. 2016-01-28 14:56:15 -08:00
database-setup-query-builder-spec.coffee perf(db): Use subselect to improve thread list query perf (53%!) 2016-04-11 13:29:05 -07:00
database-store-spec.coffee feat(tasks): add Create, Update, Destroy tasks plus spec & lint fixes 2016-01-15 15:16:21 -05:00
database-transaction-spec.coffee perf(db): Use subselect to improve thread list query perf (53%!) 2016-04-11 13:29:05 -07:00
draft-factory-spec.es6 fix(fwd): Do not mention Bcc'd recipeints in forward headers #1873 2016-04-06 14:51:17 -07:00
draft-store-proxy-spec.coffee fix(syncback): Bidirectional transforms, ready-to-send saved state 2016-03-16 19:27:12 -07:00
draft-store-spec.es6 fix(composer): Show when rendered, send draft JSON to composer windows 2016-04-04 18:30:50 -07:00
file-download-store-spec.coffee fix(downloads): Properly handle network errors, retries of downloads 2016-03-08 18:32:47 -08:00
file-upload-store-spec.coffee feat(dock-icon): Drop files to attach them to new msg 2016-03-17 13:14:55 -07:00
focused-contacts-store-spec.coffee refactor(spec) move spec-nylas to spec 2015-10-01 21:39:44 -07:00
focused-content-store-spec.coffee Merge branch 'master' into unified-inbox 2016-01-25 17:28:29 -08:00
focused-perspective-store-spec.coffee fix(perspective): Fix specs for FocusedPerspectiveStore 2016-04-11 07:59:40 -07:00
message-store-spec.coffee fix(bodies): Move loading into component, add retry, loading spinner 2016-03-09 19:14:54 -08:00
nylas-sync-status-store-spec.es6 fix(specs): Remove fdescribe 2016-03-14 15:39:42 -07:00
task-queue-spec.coffee feat(offline-status): Show a bar when not connected to the API 2016-04-04 17:11:09 -07:00