跳至内容
菜单
此问题已终结
2 回复
4443 查看

When should I use SQL Query or ORM Search Method to get better performance?
For instance:
Should I use this

query = """
        select distinct license_plate_number from car_car
        where state not in ('cancel', 'sold')
        and license_plate_number = '{}';
        """.format(license_plate_number)
self.env.cr.execute(query)
cars = self.env.cr.dictfetchall()
or this:
cars = self.search([
    ('license_plate_number', '=', self.license_plate_number),
    ('state', 'not in', ('cancel', 'sold'))
])


形象
丢弃
最佳答案

Hi,

Query is much faster than ORM. And when we use query we should take care as it bypass the orm layers, the security(rules and access rights) wont be considered. If it is small operation, go with orm layer, and for reporting and all use query.

Thanks & Regards

形象
丢弃
相关帖文 回复 查看 活动
1
1月 25
949
0
6月 20
2636
2
8月 23
10434
1
7月 25
209
0
2月 25
1106