I am using the code below to retrieve data from different lists, but I see that it is slower than Content Search Web part. The returned rows are the same 28 in total, but it takes more time csom to display the results. Imagine if I have 1000 items, it will take forever.
My questions are, what can I do to improve the performance and how can I measure the time it took to return the results?
I thought of using this class System.Diagnostics.Stopwatch()
, but it does not exist in javascript or does it?
One thing though, I can't use Content Search Web part because, we have SharePoint standard on our production server.
SP.SOD.executeFunc('sp.js', 'SP.ClientContext',function(){
SP.SOD.executeFunc('sp.search.js','Microsoft.SharePoint.Client.Search.Query.KeywordQuery',function (){
var queryText = "ContentTypeId:0x010066FA3DE3E334C841B418C82CC475A227*";
var clientContext = new SP.ClientContext("http://dev:5050");
var contextSite = clientContext.get_site();
var keywordQuery = new Microsoft.SharePoint.Client.Search.Query.KeywordQuery(clientContext);
keywordQuery.set_queryText(queryText);
keywordQuery.set_rowLimit(500);
keywordQuery.set_trimDuplicates(false);
var searchExecutor = new Microsoft.SharePoint.Client.Search.Query.SearchExecutor(clientContext);
var results = searchExecutor.executeQuery(keywordQuery);
clientContext.executeQueryAsync(onQuerySuccess, onQueryError);
function onQuerySuccess()
{
var oTable = $('#articlesOverview').DataTable({
"iDisplayLength": 25,
"iTotalRecords": 57,
"iTotalDisplayRecords": 57,
"bDestroy": true,
"bProcessing":true,
"aaData":results.m_value.ResultTables[0].ResultRows,
"aoColumns":[
{
"mData":"Title"
},
{"mData":"Path","visible": false},
]
});
}
function onQueryError(sender, args)
{
alert("call failed. Error: " + args.get_message());
}
});
});