This question has been flagged
1 Reply
3723 Views

Is there any speed issue when using CR and ORM specially in querying records (e.g. getting all records in table)?

using cr:

*cr.execute('SELECT * FROM Table')

using ORM:

*self.search(cr,uid,[],context=None) or

*self.pool.get('table.table').search(cr,uid,[],context=None)

Avatar
Discard
Best Answer

Not that I know of. Sometimes queries should perform better because you directly relate to the required fields and skip the other fields.

Do note however: Relational fields and fields using "store = false" will NOT show in the database. So if you run a query on the object, those fields will be impossible to retrieve. Therefor, the ORM has a slight advantage.

Avatar
Discard

HAd some cases where lenght of domain is restricted to 256 characters... so ORM has a benefit of user acces rights check, and can read functional fields; while sql approach is better and faster for more complex data select... also much faster when taking big datasets on models ( 100k + records)

Author

Tha't I've noticed on a transactional table specially in stock move model. I had thousands of records in the table and I need to get the quantity of products per location and I just wondering why too slow to query them. In fact qty available field in product model uses the same model but I noticed it is using CR approach so it came to my mind to post this kind of doubt.