Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] prefetch issues on computed/related fields
When deciding to prefetch records (getting records from the cache with no value for the field being fetched), if the field was computed determine_value would just get all records, not limited by the normal prefetch limit, for large recordsets this would generate gigantic prefetch lists for records we may not need at all. Fix by applying the PREFETCH_MAX limit to records from the cache as is done in _prefetch_field. Complementarily, when traversing related fields the prefetch environment would be lost and every record would get an empty prefetch environment, so the values would ultimately be read one by one. Example: select (search) 1000 product.product records, access a related field (e.g. categ_id) in a loop, on the first iteration the system would first read 1000 templates, then it would read each categ_id individually, resulting in >1000 SQL queries rather than the ~2 we would expect. Fixes odoo#18511
- Loading branch information
5007e38
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sle-odoo cf odoo#18644 (comment) it looks like the second chunk loses the prefetch info, and there could be an additional one for relational fields.