I have a many-to-many mapping between profiles
and categories
. This query:
$profiles = new Profile();
$profiles->where('foobar_flag',1);
$profiles->where_related($category);
$profiles->get();
Is taking almost 30 seconds to run, with about 1000 entries in that profiles table. There is also a category table, and a profiles_categories table. I end up with a staggering 4000 queries per execution.
How do I make this faster?