summaryrefslogtreecommitdiff
path: root/addons/test_mail/tests/test_performance.py
diff options
context:
space:
mode:
authorThibault Delavallée <tde@odoo.com>2018-02-23 14:36:40 +0100
committerThibault Delavallée <tde@odoo.com>2018-02-26 16:58:35 +0100
commitf727e9d9b6a2029b8625ecff229ccd742598322b (patch)
treec90f1d1a73ab659f7482e985adf5b6ee343cb74f /addons/test_mail/tests/test_performance.py
parent2966d4faedb2817039ed608dff48acfda418109e (diff)
[REF] rating: avoid storing rating_value on mail.message
Currently the rating value coming from the rating application is stored on the message it belongs to. However storing it is not necessary as there is no direct search using it. Having a computed field is sufficient for all use cases we currently have in Odoo. Removing the store allow to gain queries. Indeed the field is not computed anymore after each message creation meaning we save queries by not having to check existing ratings. It allows to gain a lot of computation as mail.message is a critical model. On the whole community runbot when installing all modules this leads to a gain of more than 14K queries on 585K which means 2.4% of performances increase. Considering the code size of this optimization this is quite an interesting result. Looking at test_mail performance tests we gain several queries (2/3) for each new message which is coherent with the model change. Finally it allows to lessen the performance difference between tests done with test mail only and tests done with other modules already installed. This is especially simple mail thread-enable records. Related to task ID 51523. #Closes #23294. Done with blessing of @jem-odoo .
Diffstat (limited to 'addons/test_mail/tests/test_performance.py')
-rw-r--r--addons/test_mail/tests/test_performance.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/addons/test_mail/tests/test_performance.py b/addons/test_mail/tests/test_performance.py
index 389503de9bd..232fc5f97ac 100644
--- a/addons/test_mail/tests/test_performance.py
+++ b/addons/test_mail/tests/test_performance.py
@@ -77,7 +77,7 @@ class TestMailPerformance(TransactionCase):
'partner_id': self.env.ref('base.res_partner_12').id,
})
- with self.assertQueryCount(admin=10, demo=10): # test_mail only: 8 - 8
+ with self.assertQueryCount(admin=8, demo=8): # test_mail only: 8 - 8
record.track = 'X'
@users('admin', 'demo')
@@ -93,13 +93,13 @@ class TestMailPerformance(TransactionCase):
@warmup
def test_create_mail_with_tracking(self):
""" Create records inheriting from 'mail.thread' (with field tracking). """
- with self.assertQueryCount(admin=22, demo=22): # test_mail only: 18 - 18
+ with self.assertQueryCount(admin=18, demo=18): # test_mail only: 18 - 18
self.env['test_performance.mail'].create({'name': 'X'})
@users('admin', 'emp')
@warmup
def test_create_mail_simple(self):
- with self.assertQueryCount(admin=12, emp=12): # test_mail only: 10 - 10
+ with self.assertQueryCount(admin=10, emp=10): # test_mail only: 10 - 10
self.env['mail.test.simple'].create({'name': 'Test'})
@users('admin', 'emp')
@@ -137,7 +137,7 @@ class TestAdvMailPerformance(TransactionCase):
def test_adv_activity(self):
model = self.env['mail.test.activity']
- with self.assertQueryCount(admin=12, emp=12): # test_mail only: 10 - 10
+ with self.assertQueryCount(admin=10, emp=10): # test_mail only: 10 - 10
model.create({'name': 'Test'})
@users('admin', 'emp')
@@ -243,7 +243,7 @@ class TestHeavyMailPerformance(TransactionCase):
self.umbrella.message_subscribe(self.user_portal.partner_id.ids)
record = self.umbrella.sudo(self.env.user)
- with self.assertQueryCount(admin=120, emp=153): # com runbot 118 - 151 // test_mail only: 114 - 146
+ with self.assertQueryCount(admin=118, emp=150): # com runbot 116 - 148 // test_mail only: 114 - 146
record.message_post(
body='<p>Test Post Performances</p>',
message_type='comment',
@@ -260,7 +260,7 @@ class TestHeavyMailPerformance(TransactionCase):
record = self.umbrella.sudo(self.env.user)
template_id = self.env.ref('test_mail.mail_test_tpl').id
- with self.assertQueryCount(admin=145, emp=193): # com runbot 143 - 191 // test_mail only: 137 - 183
+ with self.assertQueryCount(admin=141, emp=187): # com runbot 139 - 185 // test_mail only: 137 - 183
record.message_post_with_template(template_id, message_type='comment', composition_mode='comment')
self.assertEqual(record.message_ids[0].body, '<p>Adding stuff on %s</p>' % record.name)
@@ -276,7 +276,7 @@ class TestHeavyMailPerformance(TransactionCase):
customer_id = self.customer.id
user_id = self.user_portal.id
- with self.assertQueryCount(admin=332, emp=394): # test_mail only: 319 - 379
+ with self.assertQueryCount(admin=326, emp=386): # test_mail only: 319 - 379
rec = self.env['mail.test.full'].create({
'name': 'Test',
'umbrella_id': umbrella_id,
@@ -315,7 +315,7 @@ class TestHeavyMailPerformance(TransactionCase):
})
self.assertEqual(rec.message_partner_ids, self.user_portal.partner_id | self.env.user.partner_id)
- with self.assertQueryCount(admin=235, emp=275): # test_mail only: 228 - 267
+ with self.assertQueryCount(admin=233, emp=272): # test_mail only: 228 - 267
rec.write({
'name': 'Test2',
'umbrella_id': umbrella_id,