تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
3718 أدوات العرض

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
فبراير 19
4975
2
ديسمبر 23
14535
0
أكتوبر 23
33
3
أكتوبر 23
788
1
أكتوبر 23
569