[Dbix-class] Prefetch multiple many_to_many?

Matt S Trout dbix-class at trout.me.uk
Sat Nov 3 20:56:05 GMT 2007


On Sat, Nov 03, 2007 at 06:23:57PM +0100, Ben Staude wrote:
> Hi,
> 
> I have a setup like the many_to_many-example Actor/Role in the docs, but the 
> Actor has another many_to_many relationshiop to, for example, languages:
> 
> Actor->many_to_many(roles=> 'actor_roles', 'role');
> Actor->many_to_many(languages => 'actor_languages', 'language');
> 
> When selecting an Actor, I'd like to prefetch his roles and languages. I'm not 
> yet sure whether this really makes sense with respect to performance for my 
> application, but at least I want to understand what's going wrong when trying 
> to do so:
> 
> # Get actors by ids
> my @actors = $schema->resultset('Actor')->search(
>                 { 'me.id' => { -in => \@actor_ids } },
> 		{ prefetch => { actor_roles => 'role',
> 		                actor_languages => 'language' } })->all;

We can't currently prefetch more than one has_many rel at the same level.

Sorry.

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director                    http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/            http://www.shadowcat.co.uk/servers/



More information about the DBIx-Class mailing list