diff options
| author | Olivier Dony <odo@odoo.com> | 2018-09-19 23:22:56 +0200 |
|---|---|---|
| committer | Olivier Dony <odo@odoo.com> | 2018-09-20 12:41:03 +0200 |
| commit | 84af9382e2315964209bb065945b5d9116ddb11a (patch) | |
| tree | 75213c902c73a0976fa8961fe425bc4eaa23fcfd /addons/web/static/src/js/views/basic/basic_controller.js | |
| parent | ec4f7bc2156dcda1b14fd1bcebd116e08b393fd2 (diff) | |
[IMP] mail: avoid costly queries on messages
The combined domain for moderated messages used to trigger a complex
database query with two OR conditions on the mail_message table.
Unfortunately PostgreSQL seems to be unable to optimize this with
indexes, or to detect that one of the conditions is void (included `AND
FALSE`). On large mail_message tables, this significantly slows down
calls to message_fetch, e.g. 6s instead of ~70ms, while returning the
same results.
As a workaround, move the logic for generating the moderation domain to
the server side, where it can be:
- optimized out when the user is not a moderator
- split into 2 distinct DB queries in order to avoid the pathological
case
After this change, calls to message_fetch with and without messages
to moderate execute in respectively ~50ms and ~150ms, instead of 6s, in
a test database with 25 million messages.
The modified message_fetch signature is backwards-compatible.
+ modified mock server used for the tests, which unfortunately
duplicates most of the business logic.
Diffstat (limited to 'addons/web/static/src/js/views/basic/basic_controller.js')
0 files changed, 0 insertions, 0 deletions
