Jump to content

SQL query taking too long to process


skeener

Recommended Posts

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....

Link to comment
https://forums.phpfreaks.com/topic/56161-sql-query-taking-too-long-to-process/
Share on other sites

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.