Another thing to consider for improving speed overall is to not do a Select *, but just get the fields you want.
-w-
>I have a SQL statement I want to use:
>
>SELECT * FROM CONTDB WHERE IDNUM IN (SELECT IDNUM FROM AGENT_NUMS WHERE AGENT_NUM="33C212")
>
>It runs in 30 to 40 seconds.
>
>The following statements give me the same data is less than 1 second. Is there anything I can do to make the first statement run as quickly? IDNUM is an Integer, indexed in both tables, primary key for contdb.
>
>
>SELECT contdb.* FROM CONTDB RIGHT JOIN AGENT_NUMS ON Contdb.IDNUM = agent_nums.idnum WHERE agent_nums.agent_NUM="33C212"
>
>SELECT * FROM CONTDB WHERE IDNUM = (SELECT IDNUM FROM AGENT_NUMS WHERE AGENT_NUM="33C212")
Wayne Myers, MCSD
Senior Consultant
Forte' Incorporated
"The only things you can take to heaven are those which you give away" Author Unknown