[Dbix-class] D::C generates unneccessary duplicate joins..

Jess Robinson castaway at desert-island.demon.co.uk
Fri Jul 7 08:57:04 CEST 2006



On Thu, 6 Jul 2006, Toby Corkindale wrote:

> On Thu, Jul 06, 2006 at 01:49:12PM +0100, Jess Robinson wrote:
>> On Wed, 5 Jul 2006, Toby Corkindale wrote:
>>> Hi,
>>> I'm trying to work out how to optimise a query. D::C is generating twice as
>>> many joins as neccessary, which adds up to hurt performance in extended
>>> cases of the example I give below.
>>>
>>> An example query wants to select objects which have metadata.value=foo and
>>> metadata.value=bar.
>>>
>>> One method is to do this:
>>> Using a objects->search(
>>>    { metadata.value => foo, metadata_2.value => bar },
>>>    { join => [ { objmetadata => metadata }, {objmetadata => metadata } ] }
>>>    );
>>>
>>
>> Well you asked it to. Shouldnt that be something like:
>>
>> Using a objects->search(
>>     { metadata.value => foo, metadata_2.value => bar },
>>     { join => { objmetadata => ['metadata', 'metadata'] }
>>      );
>>
>> ??
>>
>>
>> Also, what a horrible wquery, why isnt that just:
>>
>> .. WHERE metadata.value = foo OR metadata.value = bar
>
> Actually, it'd be AND, nor OR, I think?
>
> Either way, I think I mixed the example I gave up a bit.. You're perfectly
> right, it could be written much easier. Erk.
>

Erm.. no.. cos if a value = 'A' AND its 'B' at the same time, then 
something is wrong with your DB ;)

Jess




More information about the Dbix-class mailing list