3

I am running a sharepoint caml query where I want to check that a field on an item is equal to one of many values. I do this dynamically and may wish to check against many hundreds of values.

I found that when performing a query with 780 OR elements I got an error related to server memory. Obviously this is variable across environments, but I am looking for some guidelines suggesting a maximum query length to which I should cap.

Thanks!

4
  • 2
    Why do you need those 780 OR statements? Can you paste part of your CAML Query? Mar 7, 2011 at 5:22
  • I have a list with many folders (folders were required for security purposes). Each folder may have many items with in. I want to run a query such as: get all items from 600 of 800 folders. I am currently doing this by checking the FileRef field on the items with a very large nested OR caml query. If you have a better suggestion, by all means, PLEASE let me know
    – user2568
    Mar 7, 2011 at 6:21
  • 1
    can't you do a recursive search to flatten the folders content ?
    – Steve B
    Jul 21, 2011 at 13:20
  • or create a view that does it and utilize that view/CAML. Jul 27, 2011 at 19:41

3 Answers 3

3

Or statements are notoriously inefficient, even directly in SQL. Since the error is related to memory it seems you're hitting a hardware limit rather than any kind of built-in limit.

With this in mind, I'd recommend using a more efficient query structure, such as the <In> element to work around the issue.

2

You might want to look at U2U CAML Builder or Stramit CAML Viewer to help build your CAML. It seems like you might want to apply a content type filter instead of looking at every folder individually.

0

Add a RowLimit element to your query to match your environment's list view threshold. Not sure how you are using the query, but its use may be circumventing the limit.

RowLimit Element

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.