Vauxoo / addons-vauxoo

All our modules related to developments that solves generic issues on Odoo, or that solve internal problems on Odoo Core, if something is here, maybe it is solving an issue in your company, try it and report what you see.
http://www.vauxoo.com
193 stars 288 forks source link

[IMP] Rewriting name to improve performance #1235

Closed hbto closed 7 years ago

hbto commented 7 years ago

[IMP] Caching _name_get method to improve performance in stock.location related searches.

hbto commented 7 years ago

@nhomar @moylop260 this is the meanwhile performance improve we were talking about in order to later applied a more thorough improve performance refactorization.

This cache reduced the calls from 1300 to 250 unique calls. Regards

hbto commented 7 years ago

could add a print screen (using private url from google drive incorder to avoid show private info) to see the locations with a production database?

(Link share as private Vauxoo People only) https://drive.google.com/a/vauxoo.com/file/d/0B1w9gokcJL9hU28teFBZVGVqTHc/view?usp=sharing

hbto commented 7 years ago

What about use this logic for get_warehouse method? in order to compute faster the other pieces of code where this method is involed

If an improvement is done on https://github.com/odoo/odoo/blob/11.0/addons/stock/models/stock_location.py#L114-L119

that would mean that the improvement is done over one single record rather than several records as done here:

        query = self._cr.mogrify('''
            SELECT
                sl.id AS location_id,
                ARRAY_AGG(sw.id) AS warehouse_id
            FROM stock_location sl, stock_location sl_wh
            INNER JOIN stock_warehouse sw ON sw.view_location_id = sl_wh.id
            WHERE
                sl_wh.parent_left <= sl.parent_left
                AND sl_wh.parent_right <= sl.parent_left
                AND sl.id IN %(ids)s
            GROUP BY sl.id
        ''', {'ids': tuple(self._ids)})

so the improvement that can be proposed to https://github.com/odoo/odoo/blob/11.0/addons/stock/models/stock_location.py#L114-L119 would be:

        query = self._cr.mogrify('''
            SELECT
                sw.id AS warehouse_id
            FROM stock_location sl, stock_location sl_wh
            INNER JOIN stock_warehouse sw ON sw.view_location_id = sl_wh.id
            WHERE
                sl_wh.parent_left <= sl.parent_left
                AND sl_wh.parent_right <= sl.parent_left
                AND sl.id IN %(ids)s
            LIMIT 1
        ''', {'ids': tuple(self._ids)})

Please advice if any other idea arises, or if I got wrong your idea

hbto commented 7 years ago

@moylop260 mogrify has gone