Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Need a faster way to handle a massive IN clause

$
0
0

I have a query that has a dynamically created ID list for an IN clause that may contain up to  100,000 IDs. Is there a trick that I can do to reduce the run time on the query. (Function, Stored Procedure, etc.)

SELECT     *
FROM         Cases INNER JOIN
                      Users ON Users.UserId = Cases.ReferenceUserID
WHERE     (Cases.CaseLogTypeID = 8) AND (Cases.CaseLogPrivate <> 1 OR
                      Cases.CaseLogPrivate IS NULL) AND (Cases.ReferenceUserID IN (/* Insert IDs Here*/)) AND 
                      (Cases.CaseActive = 1) AND (NOT(Cases.ParentTitle LIKE 'Place title here')) AND 
                      (Cases.RespondedStatus IN (0, 1))
ORDER BY vCases.DateCreated DESC

I am willing to try anything as long as I can still pass a 1,2,3,4,5,6,7,8 type string over to the query.

Thanks so much for any help with this.


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>