skeener Posted June 19, 2007 Share Posted June 19, 2007 dear guys. i have this one problem, where the sql statements really took very long time to be processed. It took more than 1 minute, depending on the total data in the table. I guest this have to do with the 'count' statements. here is the code: ------------------------------------------------------------ $sql = "SELECT company,theID,abbs,A as Active,N as Nonactive,(A+N) as Total FROM( select distinct D.nama As company, C.domID As theID, D.abbrew As abbs, count(distinct case when B.ids is NOT NULL THEN A.dauserid END) As A, count(distinct case when B.ids is NULL THEN A.dauserid END) As N FROM tableuser A LEFT OUTER JOIN tabletranscript B on (A.dauserid=B.dauserid) INNER JOIN thedommember C ON(C.entitybuktiID=1 AND C.mypriority=1 AND C.entitybuktiID=A.dauserid) INNER JOIN mydomain D ON (C.domID=".$getID.") GROUP BY D.nama, C.domID, D.abbrew ORDER BY company )"; Hope any of you can simplify this statements into a query that doesnt take ages to be processed. Thanks in advance.... Quote Link to comment https://forums.phpfreaks.com/topic/56161-sql-query-taking-too-long-to-process/ Share on other sites More sharing options...
sushant_d84 Posted July 2, 2007 Share Posted July 2, 2007 Well ... May be this i usefull for u ...... First create the Index on the fields which are IMPs.. like dauserid entitybuktiID=1 domID Quote Link to comment https://forums.phpfreaks.com/topic/56161-sql-query-taking-too-long-to-process/#findComment-287881 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.