跳至內容
選單
此問題已被標幟
1 回覆
3927 瀏覽次數

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.

相關帖文 回覆 瀏覽次數 活動
0
2月 19
5229
2
12月 23
14943
0
10月 23
33
3
10月 23
790
1
10月 23
569