Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

bad query

Status
Not open for further replies.

misuk11

Programmer
Mar 10, 2005
1
GB
Hi guys

Can anyone give me some pointers on the SQL below. It seems to freeze and doesnt return any results. Ive left it running for a few hours and have had to terminate it every time


SELECT
mm_file_id_cod,
mm_move_moved_dtm,
mm_move_loc_nam
FROM
mm_file
INNER JOIN
mm_move ON mm_move.mm_file_key = mm_file.mm_file_key
WHERE
mm_move_loc_nam IN ('ARCUS','ARCUS.','ARCUS..','ARCUS...','ARCUS/','.ARCUS','arcus','ARCUS: Reading','ARCUS: Western Avenue') AND
mm_move.mm_move_moved_dtm = (SELECT MAX(m1.mm_move_moved_dtm)
FROM
mm_move m1
WHERE
m1.mm_file_key = mm_move.mm_file_key)

table mm_move currently has over 4 million rows, table mm_file has over 770,000.

tia
Mark
 
can you please run it with
Code:
SET SHOWPLAN, NOEXEC ON
to see if all the indexes on your tables are correct and post us the results?

"A long life is when each day is full and every hour wide!"
(A Jewish Mentor)
M. [hourglass]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top