Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
3892 Lượt xem

I'm wondering what is faster or is there no difference between

for rec in self:
    partner = rec.env['res.partner'].search() # or any other orm method

OR

partner_env = self.env['res.partner']
for rec in self:
    partner = partner_env.search() # or any other orm method

I'm creating a sync with Odoo from other older custom CRM/ERPs and the sync has to go trough 100+, 1000+ or even 10000+ records. So every small performance boost helps.

So what method is faster and why?


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi Samo:

The 2nd option (using a variable) will be marginally faster because the recordset is built once and reused inside the loop.

Ảnh đại diện
Huỷ bỏ
Tác giả

thanks! thought so.

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 2 19
5184
2
thg 12 23
14903
0
thg 10 23
33
3
thg 10 23
789
1
thg 10 23
569