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
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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