Results 1 to 3 of 3

Thread: which fields should be indexed to speed up a query

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2001
    Location
    didn't decide yet
    Posts
    566

    which fields should be indexed to speed up a query

    here is the query but is way to slow
    Code:
    SELECT dbfPATIENT.PNAME AS PatientName, dbfFANAL.RESULT, dbfEXAM.EXNAME, dbfEXAM.RCOLS, dbfEXAM.RROWS, dbfEXAM.RPIC, dbfEXAM.ANSPIC, dbfDOCTOR.DOCNAME, dbfDOCTOR.DOCTOR, dbfFANAL.FANAL AS FANALID
    FROM dbfDOCTOR INNER JOIN (((dbfPATIENT INNER JOIN dbfIDFILE ON dbfPATIENT.PATIENT = dbfIDFILE.PATIENT) INNER JOIN dbfFANAL ON dbfIDFILE.ID = dbfFANAL.ID) INNER JOIN dbfEXAM ON dbfFANAL.EXAM = dbfEXAM.EXAM) ON dbfDOCTOR.DOCTOR = dbfIDFILE.DOCTOR
    WHERE (((dbfFANAL.RESULT) Is Not Null) AND ((dbfDOCTOR.DOCTOR) In (340,18,194,446,171,66,99,24,28,34,61,83,141,175,33,78,127,177,156,112,244,238,18,240,312,51,102,107,136,533,506,178,508,487,475)) AND ((dbfFANAL.PRINTED)=0));
    Come and get our ISDN CallerID http://www.3wm.biz

  2. #2
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    index the fields that contain only unique data for that record. such as an ID field or something similar.
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  3. #3
    Hyperactive Member JMvVliet's Avatar
    Join Date
    May 2001
    Location
    Papendrecht, Netherlands
    Posts
    310
    Also to the fields you are heavily ordering on (not in your SQL statement) and the fields you are heavily searching for, in your SQL statement:

    dbfDOCTOR.DOCTOR

    And on the fields with unique values in each table you are using in the query.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width