[Dbix-class] Multiple belongs_to relationships referencing same class

Jess Robinson castaway at desert-island.me.uk
Fri May 4 20:36:52 GMT 2007



On Wed, 2 May 2007, Tobias Kremer wrote:

>> I've not quite understood most of this thread, but it sounds like what you
>> want is:
>>
>> Table with user1_id, user2_id,
>>
>> query that returns all user2_id matching a given user_id AND returns all
>> user1_id that match when user2_is the given user_id.. correct?
>>
>> I have this with DBIC, no unions involved ;)
>
> Have you tried your approach with a user table that has approximately
> 250.000 entries? Unfortunately, the resulting LEFT JOIN with OR condition
> on this table takes about 10 seconds on my system because MySQL considers
> all rows from the user table :( Any ideas on how to optimize this?
>
> Thanx again!


Hmm,m I dont have near as many.. (mebbe 8k), and its fast enough (not on 
mysql ;)

When asking this sort of question it's probably clever if you dump the SQL 
that DBIC produced into your email.

Jess




More information about the Dbix-class mailing list