You don't just need indexes on the primary keys, you also need them on the foreign keys, as when you do a search on a many_to_many relationship, DBIC will do a query with a foreign key join.
Take a look at the examples in DBIx:Class:Relationship under many_to_many.
In one of those examples, if you do $actor->roles(), then your database has to get the primary key of the actor, run a query on the ActorRoles table for all entries matching that actor_id, look at the role_id in each matching row, and then return all roles that match. The query will be something like this:
select * from tblRoles r where r.role_id IN ( select role_id from tblA +ctorRole ar where ar.actor_id = ? )
Unless there is an index on actor_id in the ActorRoles table, the query will be very slow.
In reply to Re^3: DBIx startup slow
by chrestomanci
in thread DBIx startup slow
by anjalis
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |