mysql - Why is left joining in my query so much slower than lazy loading? -
i using doctrine2 symfony2. have query in userrepository looks this:
$qb = $this->createquerybuilder('u') ->addselect('s', 'p', 'a', 'fp', 'ea', 'c') ->leftjoin('u.subscription', 's') ->leftjoin('s.plan', 'p') ->leftjoin('u.applications', 'a') ->leftjoin('u.facebook_pages', 'fp') ->leftjoin('u.editable_apps', 'ea') ->leftjoin('u.coupons_redeemed', 'c') ->where('u = :user') ->setparameter('user', $user) ; return $qb->getquery()->getsingleresult();
according symfony profiler, 1 query takes around 63 ms
. when comment out a
, fp
left joins , instead user object , $user->getfacebookpages()
, $user->getapplications()
, have 3 queries take around 3.50 ms
.
how can make query left joins fast lazy loading related entities?
Comments
Post a Comment