[6.0] Useless read on product.product make openerp very slow
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Magento OpenERP Connector |
Fix Released
|
Undecided
|
Unassigned | ||
Odoo Server (MOVED TO GITHUB) |
Fix Released
|
Low
|
Jay Vora (Serpent Consulting Services) |
Bug Description
Hi
Two of my customers (who have maintenance contract) have some very bad performance when they open the product product menu.
Actually they are using the V5 version but as I plan to migrate them, I start to work on the V6 performance. After some inspection I understand why opening the menu is so slow.
Indeed when you try to read only one field (for example the price_list) by doing : product.price_list, the ORM launch a read request on all product fields (as my customers use Magento they can have more than 100 fields!!)
You can reproduce this bug easily and without the module magentoerpconnect, you just have to install the module product
Open the file server/
def read(self, cr, user, ids, fields=None, context=None, load='_
+ print 'fields', fields
+ if fields and 'produce_delay' in fields and len(fields)>2:
+ print jkjkjk
Restart the server and open the menu sale=>product=
The server will raise an error
And here is the stack trace
fields ['ean13', 'price_extra', 'default_code', 'name_template', 'active', 'variants', 'product_tmpl_id', 'price_margin', 'warranty', 'supply_method', 'uos_id', 'list_price', 'weight', 'standard_price', 'mes_type', 'uom_id', 'description_
[2011-03-08 10:25:07,
Traceback (most recent call last):
File "/home/
return f(self, dbname, *args, **kwargs)
File "/home/
res = self.execute_cr(cr, uid, obj, method, *args, **kw)
File "/home/
return getattr(object, method)(cr, uid, *args, **kw)
File "/home/
result = self._read_flat(cr, user, select, fields, context, load)
File "/home/
res2 = self._columns[
File "/home/
res = self._fnct(obj, cr, user, ids, name, self._arg, context)
File "/home/
res[product.id] = product.list_price
File "/home/
return self[name]
File "/home/
field_values = self._table.
File "/home/
print jkjkjk
NameError: global name 'jkjkjk' is not defined
As you can see when we try to read only one field 'list_price' the ORM will try to read this fields => 'ean13', 'price_extra', 'default_code', 'name_template', 'active', 'variants', 'product_tmpl_id', 'price_margin', 'warranty', 'supply_method', 'uos_id', 'list_price', 'weight', 'standard_price', 'mes_type', 'uom_id', 'description_
The problem is in the function def __getitem__(self, name): line 192 (in the same file).
if col._prefetch:
# gen the list of "local" (ie not inherited) fields which are classic or many2one
fields_to_fetch = filter(lambda x: x[1]._classic_
# gen the list of inherited fields
inherits = map(lambda x: (x[0], x[1][2]), self._table.
# complete the field list with the inherited fields which are classic or many2one
fields_to_fetch += filter(lambda x: x[1]._classic_
# otherwise we fetch only that field
else:
fields_to_fetch = [(name, col)]
If you add some print you will see that the value of "name" is 'price_list' and the value of "col._prefetch" is 'True' and so all fields are added to the fields_to_fetch. Normally as we when to read only one field we have to execute the code "fields_to_fetch = [(name, col)]".
Best Regards
Changed in openobject-server: | |
assignee: | nobody → Jay Vora (OpenERP) (jvo-openerp) |
tags: | added: maintenance |
Changed in openobject-server: | |
importance: | Undecided → Low |
I agree that this is a big mess indeed and slows down the system drastically.
In the case of magentoerpconnect this could be overcome by redoing the whole system in EAV [1]. Thats quite a bit of work though but could solve other bugs [2].
[1] http:// en.wikipedia. org/wiki/ Entity- attribute- value_model /bugs.launchpad .net/magentoerp connect/ +bug/648667
[2] https:/