Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
3879 มุมมอง

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?


อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi Samo:

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

อวตาร
ละทิ้ง
ผู้เขียน

thanks! thought so.

Related Posts ตอบกลับ มุมมอง กิจกรรม
0
ก.พ. 19
5178
Odoo Mail Sending Limit แก้ไขแล้ว
2
ธ.ค. 23
14901
0
ต.ค. 23
33
3
ต.ค. 23
789
1
ต.ค. 23
569