SQL Joins on varchar fields timing out

Posted by CL4NCY on Stack Overflow See other posts from Stack Overflow or by CL4NCY
Published on 2010-03-08T17:13:49Z Indexed on 2010/03/08 17:21 UTC
Read the original article Hit count: 392

Filed under:
|
|

Hi, I have a join which deletes rows that match another table but the joining fields have to be a large varchar (250 chars). I know this isn't ideal but I can't think of a better way. Here's my query:

DELETE P 
FROM dbo.FeedPhotos AS P
INNER JOIN dbo.ListingPhotos AS P1 ON P.photo = P1.feedImage
INNER JOIN dbo.Listings AS L ON P.accountID = L.accountID
WHERE P.feedID = @feedID

This query is constantly timing out even though there are less than 1000 rows in the ListingPhotos table.

Any help would be appreciated.

© Stack Overflow or respective owner

Related posts about sql

Related posts about joins