Subject Query Slow
Author Sivaraman Krishnan
Hello,
i am using ib_query for fetching this record.This is my Query.
SELECT P.OPNUMBER, P.PATIENTNAME, P.PATIENTADDRESS1, P.PATIENTADDRESS2,
P.PATIENTGUARDIAN, P.DOCTORCODE, P.AREACODE, P.REGISTRATIONDATE,
P.PATIENTAGE, P.PATIENTAGETYPE, P.PATIENTSEX,
P.CUSTOMERTYPE, P.PRIVILEGEDCUSTOMERCODE, I.IPNUMBER, I.IPSERIALNUMBER,
I.DISCHARGED, I.ADMITTINGDATE, I.PATIENTCOMPLAINT, I.BEDNUMBER,
I.CURRENTROOMCODE, I.ADMITTINGDOCTOR,
D.DISCHARGEDATE, R.ROOMNUMBER, A.AREANAME, E.EMPLOYEENAME FROM
(((((PATIENTMASTER P LEFT OUTER JOIN IPMASTER I ON P.OPNUMBER = I.OPNUMBER
AND I.IPSERIALNUMBER = (SELECT MAX(M.IPSERIALNUMBER) FROM IPMASTER M WHERE
M.OPNUMBER = P.OPNUMBER))
LEFT OUTER JOIN DISCHARGEDETAILS D ON I.IPNUMBER = D.IPNUMBER AND
I.IPSERIALNUMBER = D.IPSERIALNUMBER)
LEFT OUTER JOIN ROOMMASTER R ON I.CURRENTROOMCODE = R.ROOMCODE ) LEFT OUTER
JOIN AREAMASTER A ON P.AREACODE = A.AREACODE)
INNER JOIN EMPLOYEEMASTER E ON P.DOCTORCODE = E.EMPLOYEECODE)

This is the plan for this query:


PLAN (M INDEX (RDB$FOREIGN237))
PLAN MERGE (SORT (E NATURAL),SORT (JOIN (JOIN (JOIN (JOIN (P NATURAL,I
INDEX (RDB$FOREIGN237)),D INDEX (RDB$PRIMARY71)),R INDEX (RDB$PRIMARY41)),A
INDEX (RDB$PRIMARY34))))



For fetching the records, this query takes 14 seconds.What might be the
problem?I set the FetchWholeRows property to false.
Whether i have to change any other properties for speed up this
query?Otherwise any problem in the index?

Sivaraman