When you access data from a recordset, it makes a query in the database. With the prefetching pattern, you can reduce the number of queries made by fetching the data in batches.
The prefetching pattern for the recordsets
How to do it...
When you are working with multiple recordsets, prefetching helps reduce the number of SQL queries. It does this by fetching all of the data at once. Usually, prefetching works automatically in Odoo, but you lose this feature in certain circumstances. In this recipe, we will explore how you can use prefetching efficiently.
The following example is a normal compute method. In this method, self is the recordset of multiple records. In this kind of pattern, prefetching works perfectly. Take a look...