Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
1 Balas
3903 Tampilan

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?


Avatar
Buang
Jawaban Terbai

Hi Samo:

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

Avatar
Buang
Penulis

thanks! thought so.

Post Terkait Replies Tampilan Aktivitas
0
Feb 19
5207
2
Des 23
14909
0
Okt 23
33
3
Okt 23
789
1
Okt 23
569