There's more...

If you split recordsets, the ORM will generate a new recordset with a new prefetch context. Making operations on such recordsets will only prefetch the data for their respective records. If you want to prefetch all the records after the prefetch, you can do this by passing the prefetch dictionary in the with_prefetch() method. In the given example, we spilt the recordset into two parts. Here, we passed a common prefetch context in both recordsets, so when you fetch the data from one of them, ORM will fetch the data for the other and put the data in the cache for future use:

recordset = ... # assume recordset has 10 records
prefetch = self.env['base']._prefetch.
recordset1 = a[:5].with_prefetch(prefetch)
recordset2 = a[5:].with_prefetch(prefetch)
The prefetch context is not limited to splitting recordsets. You can also use the with_prefetch() method to have a common prefetch context between multiple recordsets. This means that when you fetch data from one record, it will fetch data for all other recordsets too.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset