<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    This join is for the "member of" field. So if you don't use this
    field you should be ok.<br>
    It is possible that other parts of the code that use this query be
    affected.<br>
    I would suggest you try adding an index on parentid instead of
    eliminating the join<br>
    Let us know how it goes.<br>
    <br>
    Joe<br>
    TSolucio<br>
    <br>
    El 09/08/11 19:38, Nicolas Larcipretti escribi&oacute;:
    <blockquote
cite="mid:CAK10WeADH0xKT8k2nfKwQT1yd3Y-iF40uJ47u8XrE1feW0jSFg@mail.gmail.com"
      type="cite">Guys,<br>
      <br>
      I've found this query while trying to enhace the Accounts popup
      performance and I need your opinion about it.<br>
      <br>
      SELECT vtiger_crmentity.crmid, vtiger_crmentity.smownerid,<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; vtiger_account.accountname, vtiger_account.email1,<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; vtiger_account.email2, vtiger_account.website,
      vtiger_account.phone,<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; vtiger_accountbillads.bill_city,<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; vtiger_accountscf.*<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; FROM vtiger_account<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; INNER JOIN vtiger_crmentity<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ON vtiger_crmentity.crmid =
      vtiger_account.accountid<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; INNER JOIN vtiger_accountbillads<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ON vtiger_account.accountid =
      vtiger_accountbillads.accountaddressid<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; INNER JOIN vtiger_accountshipads<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ON vtiger_account.accountid =
      vtiger_accountshipads.accountaddressid<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; INNER JOIN vtiger_accountscf<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ON vtiger_account.accountid =
      vtiger_accountscf.accountid<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; LEFT JOIN vtiger_groups<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ON vtiger_groups.groupid =
      vtiger_crmentity.smownerid<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; LEFT JOIN vtiger_users<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ON <a moz-do-not-send="true"
        href="http://vtiger_users.id">vtiger_users.id</a> =
      vtiger_crmentity.smownerid";&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <b style="background-color: rgb(255, 255, 0);">LEFT
        JOIN vtiger_account vtiger_account2<br>
        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ON vtiger_account.parentid =
        vtiger_account2.accountid";</b><br>
      <br>
      The highlighted join is the popup performance villain, and,
      appearently, it's result is not used in the query result. I've
      ripped it out from the query and I had 80% of performance
      improvement when loading the Accounts popup. (I have 36.000
      Accounts registered)<br>
      <br>
      Now here's the question: Does anyone knows why this left join is
      there if it's not being used? Does my action will mess with any
      other vtiger module or section? If this join is not supposed to be
      there, can we add it's remotion in vtige's roadmap?<br>
      <br>
      Cheers <br>
      <br>
      Nicolas<br>
    </blockquote>
    <br>
  </body>
</html>