如何提高symfony中多重关系的查询性能?

Hi I am using symfony 2 for my application and using sg-datatable for displaying my data, now to feed the data table i used client side not server side and using this query:

public function indexAction()
{
    $em = $this->getDoctrine()->getManager();

    $entities = $em->getRepository('MyAppBundle:Artist')
        ->createQueryBuilder('c')
        ->select('c.id, c.name, c.sex, c.priority, c.bday, c.bmonth, c.byear')
        ->getQuery()
        ->getArrayResult();

    $cacsData = $em->createQueryBuilder()
        ->select('a.id, r.name as role, c.title as work')
        ->from('MyAppBundle:CastAndCrew', 'q')
        ->innerJoin('q.role', 'r')
        ->innerJoin('q.artists', 'a')
        ->innerJoin('q.content', 'c')
        ->getQuery()
        ->getArrayResult();

    $cacs = array();
    foreach ($cacsData as $cacData) {
        if (!array_key_exists($cacData['id'], $cacs)) {
            $cacs[$cacData['id']] = array();
        }
        $cacs[$cacData['id']][] = $cacData;
    }

    foreach ($entities as &$artist) {
        if (!array_key_exists($artist['id'], $cacs)) {
            continue;
        }

        $roles    = array();
        $contents = array();

        foreach ($cacs[$artist['id']] as $cac) {
            $roles[]    = $cac['role'];
            $contents[] = $cac['work'];
        }

        $artist['role']  = implode('/', array_unique($roles));
        $artist['works'] = implode('<br>', array_unique($contents));
    }

    $encoders    = array(new JsonEncoder());
    $normalizers = array(new GetSetMethodNormalizer());
    $serializer  = new Serializer($normalizers, $encoders);
    $datatable   = $this->get("bbd_datatables.artist");
    $datatable->setData($serializer->serialize($entities, "json"));

    return $this->render('MyAppBundle:Artist:index.html.twig', array(
       "datatable" => $datatable
    ));
}

everything is fine but the problem is query time, i have 20000+ data in my table and it's taking 250+ ms and because of the client side it paused few seconds then displays the data, can any one suggest me how i can improve the performance?