简体   繁体   English

使用SPServices查询大型列表并避免列表视图阈值...功能

[英]Using SPServices to query large lists and avoiding the List View Threshold… feature

So I have a list that will have tens of thousand of items in it which I will need to perform queries upon using SPServices. 所以我有一个列表,里面有数以万计的项目,我需要在使用SPServices时执行查询。 The threshold is set to 8,000 so I'm having an issue with that. 阈值设置为8,000,所以我遇到了问题。

So far I have tried optimizing the list by putting items into folders and indexing columns that I will be using in queries. 到目前为止,我已经尝试通过将项目放入文件夹并索引我将在查询中使用的列来优化列表。

It appears that the only real trick to getting it to work is by properly indexing columns: however even with columns indexed I still have issues: 似乎让它工作的唯一真正技巧是通过正确索引列:但即使列索引,我仍然有问题:

if I index the columns "Keyword1" and "Keyword2" I can query the list just fine if I only use one of those fields in the query, but as soon as I include both of them within my Where clause with an Or predicate, I get the threshold error. 如果我索引列“Keyword1”和“Keyword2”我可以查询列表就好了如果我只在查询中使用其中一个字段,但只要我在Where子句中包含它们和Or谓词,我得到门槛错误。

The last couple of sentences here highlights the problem http://msdn.microsoft.com/en-us/library/ff798465.aspx "In this case, you could avoid the issue by indexing the Title field. This would enable SharePoint to determine the top 100 items sorted by title from the index without scanning all 10,000 list items in the database. The same concepts that apply to sort operations also apply to where clauses and join predicates in list queries. Careful use of column indexing can mitigate many large list performance issues and help you to avoid query throttling limits." 这里的最后几句话突出了问题http://msdn.microsoft.com/en-us/library/ff798465.aspx “在这种情况下,您可以通过索引标题字段来避免此问题。这将使SharePoint能够确定从索引中按标题排序的前100个项目,而不扫描数据库中的所有10,000个列表项。 适用于排序操作的相同概念也适用于列表查询中的where子句和连接谓词。仔细使用列索引可以减轻许多大型列表性能问题并帮助您避免查询限制限制。“

How can I index columns in such a way that I can perform a more complex query such as, 如何以这样的方式索引列,以便我可以执行更复杂的查询,例如:

<Query><Where><Or><Eq><FieldRef Name='Keyword1' /><Value Type='Text'>TEST1</Value></Eq><Eq><FieldRef Name='Keyword2' /><Value Type='Text'>TEST2</Value></Eq></Or></Where></Query>

I have tried a lot of options. 我尝试了很多选择。 One that I thought was promising was to query the individual folders by specifying the ViewName or FolderName in the query, but that didn't seem to get around the threshold error.. 我认为有希望的是通过在查询中指定ViewName或FolderName来查询单个文件夹,但这似乎没有绕过阈值错误。

Any tips or alternatives? 任何提示或替代方案?

Have you tried to increase the list threshhold to higher value? 您是否尝试将列表阈值增加到更高的值?

The work around is to "Override the list view threshold for an individual list by setting the SPList.EnableThrottling property to false. 解决方法是“通过将SPList.EnableThrottling属性设置为false来覆盖单个列表的列表视图阈值。

  private static void DisbaleListThrottling()
        {
           using (SPSite spSite = new SPSite("http://YourSiteNameHere.com/TeamSite/"))
            {
                using (SPWeb spWeb = spSite.OpenWeb())
                {
                    SPList spList = spWeb.Lists["MyList1"];
                    spList.EnableThrottling = false;
                    spList.Update();
                }
           }
        }

You can also use powershell:- 你也可以使用powershell: -

$web = Get-SPWeb http://whateverWeb

$list = $web.Lists[“List Title”]

$list.enablethrottling = $false

$lst.update()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM