diff options
| author | Romain Derie <rde@odoo.com> | 2020-03-26 18:06:14 +0000 |
|---|---|---|
| committer | Romain Derie <rde@odoo.com> | 2020-03-26 18:12:47 +0000 |
| commit | a5a57321c785d0c0718f413aeb8a149fbb164f95 (patch) | |
| tree | 8385b6e53b0c9eab0b9f10ac35f8f769a97582a6 /addons/website/tests/test_performance.py | |
| parent | af68fcde4858b6a1e6c672b55f1465bf29e371cc (diff) | |
[IMP] website: perf - reduce SQL queries for the website menu
Render page flow:
- Search website.page in _serve_page for requested URL
- Check if the page is visible with `is_visible`
- `is_visible` will get the `ir.ui.view` of the page
Note that this is not 'cachable' as being visible depends of now() for the
publishing date
- Render layout which is getting the website menus
Note that this can't be cached either as a menu visibility might also
depends of it's website.page visibility which depends of now()
- Checking menus `is_visible` fetch the menus pages and those pages views.
Before this commit, every level of menu hierarchy would add 2 queries.
This can be avoided by prefetching everything in once during the dispatch if we
know we will render the website menu.
In such a case, read `is_visible` on every website menus will fetch every
pages, views and menus in the lowest SQL queries possible, eg one query for
every table.
For a 3 level menus, requests goes from 20 to 12 to load a untracked page.
task-2211013
Diffstat (limited to 'addons/website/tests/test_performance.py')
| -rw-r--r-- | addons/website/tests/test_performance.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/addons/website/tests/test_performance.py b/addons/website/tests/test_performance.py index b42fa130148..9dcca13c472 100644 --- a/addons/website/tests/test_performance.py +++ b/addons/website/tests/test_performance.py @@ -113,7 +113,7 @@ class TestWebsitePerformance(UtilPerf): menu_bb.parent_id = menu_b menu_aa.parent_id = menu_a - self.assertEqual(self._get_url_hot_query(self.page.url), 22) + self.assertEqual(self._get_url_hot_query(self.page.url), 14) def test_50_perf_sql_web_content(self): # assets route /web/content/.. |
