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

Toby Corkindale tjc at wintrmute.net
Thu Jul 6 16:09:30 CEST 2006


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.

Toby

-- 
Turning and turning in the widening gyre/The falcon cannot hear the falconer;
Things fall apart, the centre cannot hold/Mere anarchy is loosed upon the world
(gpg --keyserver www.co.uk.pgp.net --recv-key B1CCF88E)



More information about the Dbix-class mailing list