1 Reply Latest reply on May 14, 2007 10:42 AM by Don Smith

    Performance problem with LEFT JOIN

    Toni Beckman Novice

      Hi,

      I have a LEFT JOIN, which looks like this:

      
      entityManager.createQuery("SELECT t FROM Template t LEFT JOIN t.messages c WHERE t.client.hostname=:ch GROUP BY t.id, t.subject, t.text, t.client ORDER BY count(c)").setParameter("ch", client.getHostname()).getResultList();
      


      The problem is that the larger the table grow the poorer the performance is. After a while it takes about 3-4 seconds to execute.

      Any ideas how I could optimize this?