[Dbix-class] don't want to hit the db again

Dagfinn Ilmari Mannsåker ilmari at ilmari.org
Tue Apr 28 22:27:47 GMT 2015


Kevin Karabian <kkarabian at turnitin.com> writes:

> Hi,
>
> Is there a way to store already retrieved related objects (related as a
> has_many) in a result object, such that calling the accessor for that
> relationship data will not hit the db again.

This is exactly what prefetch is for.

https://metacpan.org/pod/DBIx::Class::ResultSet#prefetch
https://metacpan.org/pod/DBIx::Class::ResultSet#PREFETCHING

-- 
- Twitter seems more influential [than blogs] in the 'gets reported in
  the mainstream press' sense at least.               - Matt McLeod
- That'd be because the content of a tweet is easier to condense down
  to a mainstream media article.                      - Calle Dybedahl




More information about the DBIx-Class mailing list