class Marten::DB::Query::Prefetcher
- Marten::DB::Query::Prefetcher
- Reference
- Object
Overview
The main prefetcher class.
A prefetcher is responsible for prefetching relation recordss for the records matched by a given query set. This allows to avoid N+1 queries problems for relation fields (and reverse relations) that map to multiple records.
A prefetcher is initialized with an array of records, an array of relation strings to prefetch, and an the identifier of the database to use for the prefetching queries. The prefetcher decorates the records with the prefetched records, and also caches the prefetched records for future use.