Code review comment for lp:~openerp-dev/openobject-addons/trunk-bug-1217779-mba

Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

The way the query is written strikes me as very inefficient. Why use 2 nested subqueries instead of relational joins for which the database optimizer will be able to generate a widely more efficient execution plan?

Something along the line of

select account_subscription_line.id
from account_subscription_line join account_subscription on (subscription_id=account_subscription.id) join account_model on (account_subscription.model_id=account_model.id)
where account_subscription_line.date<%s and account_subscription_line.move_id is null
and account_model.company_id=%s;

(not tested, maybe outer joins should be used)

review: Needs Information (code review, no test)

« Back to merge proposal