In this post titled "How to change the List View Threshold and Other Resource Throttling Settings", I described why you might want to use the "List View Threshold for Auditors and Administrators", which is 20,000 by default. This limit is higher than the default 5,000 List View Threshold that gets applied to all regular users. If you decide you do want to use this higher limit for some custom code or application, then the following conditions must all be met:
- The Object Model Override must be set to On.
- The code being run must be run as a user with "Full Control" or "Full Read" permissions.
- The code must explicitly request the override when using SPQuery, by setting the SPQueryThrottleMode.
If any of those conditions are not met, then the query will be subject to the regular List View Threshold, rather than the Auditor/Administrator one which is typically higher.
In this post, I'll describe how to go about doing this:
First, you have to make sure your Object Model Override is enabled (It is ON by default, so unless you've changed it, you are fine).
Next, you'll need to grant sufficient privileges to the account that will perform these queries ("Full Control" or "Full Read"). Here's how to do that:
In Central Admin:
- Click “Application Management”
- Click “Managed Web Applications”
- After selecting a specific Web Application, click “User Policy” in the Ribbon
- Click “Add Users”
- Select Zone (default: All Zones)
- Enter Permission level (either of these will suffice)
o Full Control
o Full Read
Optionally, you may want to consider changing the List View Threshold for Auditors or Administrators to a different number. For example, if you know you don't need all 20,000, then it would be a good idea to lower that number to make sure custom code does not accidentally get written inefficiently without being noticed.
Now you're ready to use the List View Threshold for Auditors and Administrators. To do so, running as that user will "Full Control" or "Full Read", you will need to run code that looks something like this:
SPQuery q1 = new SPQuery();
q1.QueryThrottleMode = SPQueryThrottleOption.Override;
There are 3 different options for SPQueryThrottleOption:
- Default – Normal behavior where all users who are not web server box administrators will be subject to the List View Threshold, including users with "Full Read" or "Full Control" permissions. This is the default behavior unless otherwise specified.
- Override – if user has “Full Control” or "Full Read" permissions, the List View Threshold for Auditors and Administrators will apply to this SPQuery, and List View Lookup Threshold will not be applied. For more info on what the List View Lookup Threshold does, read this post.
- Strict – List View threshold will apply for everyone, including web server box administrators. You can use this option to make sure that your code does not cause server stress even if it is being run as the box administrator on one of the web servers, since box administrators are not subject to the thresholds so may inadvertently slow down the servers.
Thanks for reading, please let me know if you have any questions.
Program Manager on SharePoint, MSFT.