Benjamin Hanquin (beha) 9b42ab531d [PERF] spreadsheet_account: optimize fetch_debit_credit SQL query
Issue:
Displaying the data on the dashboard accounting can take up to 1 minute

Analysis:
The spreadsheet_fetch_debit_credit function needs a domain in order to compute the formulas. The domain being set in `_build_spreadsheet_formula_domain` use a like search for account_account.code on account_move_line which is a big table. Thus it does not scale well. There is also a unnecessary complexity on adding an "OR expression" on each one of the account_id code searched for.

Solution:
It can be optimized by searching for the full exhaustive (like in SQL) codes in account.accoun since it has way less records and thus more scalable. And then use an exact condition (=) which is faster than a like search. Also adding more readable while adding the balance_domain and pnl domain only once in the whole query.

Benchmark:

| Before PR | After PR |
|:----------:|:---------:|
| 8s 51 ms | 42 ms code search + 42 ms full query |

Related ticket:
opw-3328144

Version affected:
16.0 and above

closes odoo/odoo#134889

X-original-commit: a707f8345cec8f404077b184f4b0339932c10892
Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
2023-09-08 16:48:01 +00:00
…
…
…
…
…
…
…

Build Status Tech Doc Help Nightly Builds

Odoo

Odoo is a suite of web based open source business apps.

The main Odoo Apps include an Open Source CRM, Website Builder, eCommerce, Warehouse Management, Project Management, Billing & Accounting, Point of Sale, Human Resources, Marketing, Manufacturing, ...

Odoo Apps can be used as stand-alone applications, but they also integrate seamlessly so you get a full-featured Open Source ERP when you install several Apps.

Getting started with Odoo

For a standard installation please follow the Setup instructions from the documentation.

To learn the software, we recommend the Odoo eLearning, or Scale-up, the business game. Developers can start with the developer tutorials

S
Description
No description provided
Readme LGPL-3.0
3.4 GiB
Languages
Python 49.6%
JavaScript 47.8%
SCSS 2%
CSS 0.3%
HTML 0.2%