[Dbix-class] Problem prefetching more than one relation
Jules Bean
jules at jellybean.co.uk
Thu Nov 9 14:44:08 GMT 2006
Jon Warbrick wrote:
> On Wed, 8 Nov 2006, Matt S Trout wrote:
>
>> A chain of has_manys is fine.
>>
>> For the record, I've found it's usually not very efficient to do that anyway
>> for large resultsets because of the cross product effect, and fairly
>> irrelevant for small ones.
>>
>
> Now that you've caused me to think about it properly I can see that what I
> was trying to do was probably fairly foolish. Ta. :-)
>
On the contrary, it's not foolish at all. Just not implemented.
It's just that DWIM in this case is two queries, not one. There is
nothing foolish in principle with the notion of prefetching both
has_manies if you believe you are definitely going to accessing them
both, since it does save queries. It's just that it requires a different
implementation than we currently have. The sensible thing [for DBIC to
automatically do] might be something like (1) SELECT foo.*, bar.* FROM
foo JOIN bar; (2) SELECT foo.id,baz.* FROM foo,baz (3) 'patch' the
results of the second into the objects already set up by the first.
I have little doubt that a sensible patch including a test case would be
given serious consideration :)
Jules
More information about the Dbix-class
mailing list