Hello, I'm running into performance issues with a belongsToMany relationship in Eloquent. The (simplified) database structure is as follows:
Table A:
id
Table B:
id_A
id_C
Table C:
id
Table A ~ 1k rows
Table B ~ 250k rows
Table C ~ 7k rows
Now i'm retrieving about 1000 C from a list of id's with eager loaded A's using the following query:
C::whereIn('id', $c_ids)->with('A')->get();
This query takes a crazy 10 seconds to complete. The querylog does not show any crazy queries (2 in total), with a time per query of about 500ms
Where are there 9 extra seconds coming from?
Running the query (->toSql()) directly in phpmyadmin (without LIMIT) runs in about 0.01 sec. There must be something going wrong.