List:General Discussion« Previous MessageNext Message »
From:Jim McNeely Date:March 9 2011 10:57pm
Subject:Help with slow query
View as plain text  
I am trying to set up an export query which is executing very slowly, and I was hoping I
could get some help. Here is the query:

SELECT a.IdAppt, a.IdPatient, 
p.NameLast, p.NameFirst, p.NameMI, 
a.IdProcedure, a.ProcName, CAST(CONCAT(a.ApptDate, " ", a.ApptTimeOut) AS CHAR) 
ApptDateTime, a.ApptLenMin Duration,
a.Room Primary_Resource_ID, 'R' as Primary_Resource_Type, 
t.Note, c.IdPractAffil DoctorID, af.PractName DoctorName, a.ICD9code ICD9, 
'??????' Diagnosis_free_test

from Appt_ a LEFT JOIN (patient_ p, today_ t, Copy_ c, Affil_ af) 
ON (a.IdPatient = p.IdPatient 
AND a.IdPatientDate = t.IdPatientDate 
AND CONCAT(a.IdAppt, '0') = c.IdApptType 
AND a.IdPriCarePhy = af.IdAffil)
WHERE a.ApptDate >= '2009-03-01'; 

p.IdPatient, t.IdPatientDate, c.IdApptType, and af.IdAffil are all indexed. Also I
selectively took out join parameters until there was nothing but a join on the patient
table, and it was still slow, but when I took that out, the query was extremely fast.
What might I be doing wrong?

Thanks,

Jim McNeely
Thread
Help with slow queryJim McNeely10 Mar
  • Re: Help with slow queryMySQL)10 Mar
    • Re: Help with slow queryJim McNeely10 Mar
Re: Help with slow queryJim McNeely10 Mar
  • Re: Help with slow querymos10 Mar
  • Re: Help with slow queryMySQL)10 Mar
    • Re: Help with slow queryJim McNeely10 Mar
      • Re: Help with slow queryMySQL)10 Mar
        • Re: Help with slow queryAndy Wallace10 Mar