account_statement_base_completion: useless query

Bug #1287708 reported by Guewen Baconnier @ Camptocamp on 2014-03-04
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Banking Addons
Guewen Baconnier @ Camptocamp

Bug Description


The key 'partner_memoizer' is never set in the context, so a search on all the partners is always executed.
Then, the full list of IDs is used in the next query in "WHERE id IN %s" which is really inefficient.

I guess this is dead code and propose to remove it completely.

If someone claims that there is a reason to have this key in the context (used by another module I may be unaware of), then the former search is still useless as we already know the IDs.

In all cases, a search should be done to apply the record rules, but *after* the big query so it will be done only on a subset of a few IDs.

Hmm in fact it is set. In the method itself:

        # We memoize allowed partner
        if not context.get('partner_memoizer'):
            context['partner_memoizer'] = tuple(self.pool['res.partner'].search(cr, uid, []))
        if not context['partner_memoizer']:
            return res

But I have some doubt on the efficiency of such a thing as anyway it always searches all the ids.

Changed in banking-addons:
assignee: nobody → Guewen Baconnier @ Camptocamp (gbaconnier-c2c)
description: updated

Tested with the related branch on a database with 480'000 partners on a small bank statement with only 8 lines:
Current code: 132 seconds to complete
Branch in my code: 129 seconds to complete
The lines did not autocomplete though, that means that more queries would have been issued with lines that are matched.

The current code using the big filter on all the ids seems a bit clunky to me, but changing in now will maybe not improve the performance.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers