I'm 1st time in this site and hope you all are fine.

Please consider the following SQL:

SELECT ptntPatientDetails.patientID,
FROM ptntPatientDetails

SELECT customFieldMaster.customFieldID AS CustomField,
customFieldMasterLang.customFieldTitle AS FiledTitle,
GROUP_CONCAT(CAST(IF((customFieldMaster.fieldTypeI D = 1 OR customFieldMaster.fieldTypeID = 2),
ptntPatientToCustomFieldMatchDetails.fieldDetailsV alue,
COALESCE(IF((ptntPatientToCustomFieldMatchDetails. isChecked=1),customFieldTypeDetails.fieldOptionNam e,NULL))) AS CHAR)) AS fieldValue,
INNER JOIN customFieldMasterLang
ON customFieldMaster.customFieldID = customFieldMasterLang.customFieldID

INNER JOIN customFieldTypeDetails
ON customFieldMaster.customFieldID = customFieldTypeDetails.customFieldID

LEFT JOIN ptntPatientToCustomFieldMatch
ON customFieldTypeDetails.customFieldID = ptntPatientToCustomFieldMatch.customFieldID
LEFT JOIN ptntPatientToCustomFieldMatchDetails
ON (customFieldTypeDetails.fieldDetailsID = ptntPatientToCustomFieldMatchDetails.fieldDetailsI D
AND ptntPatientToCustomFieldMatch.ID = ptntPatientToCustomFieldMatchDetails.ID)
WHERE customFieldMaster.statusID = 1
AND customFieldMaster.isDeleted = 0
AND customFieldTypeDetails.isDeleted = 0
AND customFieldMasterLang.langID = 1
GROUP BY ptntPatientToCustomFieldMatch.patientID,customFiel dMaster.customFieldID
ORDER BY ptntPatientToCustomFieldMatch.patientID

) CF
ON ptntPatientDetails.patientID = CF.patientID
WHERE ptntPatientDetails.isDeleted = 0;

in the inner part the alias CF is executing in few seconds as per expectation, but when it is Left joined with `ptntPatientDetails` it slows down and takes several minutes. I'm using MySQL 5.1

`ptntPatientDetails` contains all the patients records

(total patients >6000, total rows returned >12044)

CF returns like this:

Customfield FiledTitle value patientID
1 SSN 1234 5000
2 Hobby swiming 5000
1 SSN 5678 5001
1 SSN 7484 5020

but it does not returns all patients, i.e. patients not associated with any customfiled or have not entered values for any field, but as I need to return all the patients even if they don't entered value for any cusomfield, I left joined as:
ptntPatientDetails left join ( SELECT customFieldMaster.customFieldID,....)CF

so that I can have all the patients at least with null values if they didn't entered value.
but due to this join it slows down( result of CF returns multiple rows for a patient depending upon no. of custom field but in `ptntPatientDetails` only single row per patient).

any help will be appreciated.
tell me am I clear or need further specification..