-
Notifications
You must be signed in to change notification settings - Fork 23.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[IMP] pos_coupon: Speed-up computing domain for products and partners #164771
Conversation
@caburj What do you think? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems good but can you take a look at my comments ?
f94d0f7
to
4b73999
Compare
4b73999
to
5e5e638
Compare
LGTM 👍 |
@adgu-odoo Could you review it, please? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
You can revert what I said about literal_eval and then ping me when the runbot is green |
- Re-using result for domains duplicated - Ordering by id instead of default heavy unused order
5e5e638
to
bfb97ef
Compare
Thank you for reply! I have created the changes requested and the runbot CI is green now |
@robodoo r+ |
- Re-using result for domains duplicated - Ordering by id instead of default heavy unused order closes #164771 Signed-off-by: Adrien Guilliams (adgu) <adgu@odoo.com>
@moylop260 @adgu-odoo this pull request has forward-port PRs awaiting action (not merged or closed): |
2 similar comments
@moylop260 @adgu-odoo this pull request has forward-port PRs awaiting action (not merged or closed): |
@moylop260 @adgu-odoo this pull request has forward-port PRs awaiting action (not merged or closed): |
I have created the following FW PR manually: |
@moylop260 @adgu-odoo this pull request has forward-port PRs awaiting action (not merged or closed): |
- Re-using result for domains duplicated - Ordering by id instead of default heavy unused order closes odoo#164771 Signed-off-by: Adrien Guilliams (adgu) <adgu@odoo.com>
Opening a POS sessions our SQL profiler shows the following query executed too many times:
Checking the PY profilers the following method is reported as slow:
odoo/addons/pos_coupon/models/coupon_program.py
Line 80 in 42f5e84
The reason it is executing the same query too many times with the same domain
So, I have created this change to re-use the result if the domain is repeated
Also, the query generated has heavy
order by
order by "res_partner"."type", coalesce("res_partner"."is_company", false) desc, "res_partner"."display_name", "res_partner"."id";
Replacing by
order by "res_partner"."id"
it is fasterBefore
Execution Time: 104.256 ms
Now
Execution Time: 31.802 ms
So, it is ~4x faster for each query and it is re-using data for the same query using a LRU-Cache locally in the method