Priya
Priya

Reputation: 1425

Sharepoint Fetch data

I have sharepoint list with thousand data. If i execute query in caml query builder than it takes a second to fetch data. and when i am trying to fectch data in sharepoint with spservice / c# code than it takes 15 seconds to execute that query. Why this much is diffrent. Can any one suggest.

I am using SPService js to fetch data.The code that I have used is:

var querySkill = "<Query><Where><And><Eq><FieldRef Name='User_x003a_ID' /><Value Type='Lookup'>"+rowUserId+"</Value></Eq><And><Eq><FieldRef Name='Role_x003a_ID' /><Value Type='Lookup'>"+rowRoleId+"</Value></Eq><And><Eq><FieldRef Name='Skill_x0020_Category_x003a_ID' /><Value Type='Lookup'>"+rowCategoryId+"</Value></Eq><Eq><FieldRef Name='Skill_x0020_Group_x003a_ID' /><Value Type='Lookup'>"+rowGroupId+"</Value></Eq></And></And></And></Where></Query>"
        var camlViewFieldsSkill = "<ViewFields><FieldRef Name='Fulfillment' /></ViewFields>";
        var groupPer;
        var groupArray = new Array();
        $().SPServices({
            operation: "GetListItems",
            async: false,
            listName: "User Skills",
            CAMLQuery: querySkill,
            CAMLViewFields: camlViewFieldsSkill,
            completefunc: function (xData, Status) {
                $(xData.responseXML).find("z\\:row, row").each(function () {
                  var skillId = $(this).attr("ows_ID");
                  var skillName=$(this).attr("ows_Skill").split("#")[1];
                  var fulfilment=$(this).attr("ows_Fulfillment");
                    $(subGridSkill).jqGrid('addRowData', skillId, { id: skillId, skillid: skillId, skill:skillName, skillfulfillment: fulfilment });

                });

            }
        });

Even if i am writing server side code than also it takes 15-20 seconds to fetch data. Plz help

Regards Priya

Upvotes: 1

Views: 534

Answers (2)

lem.mallari
lem.mallari

Reputation: 1275

Here is a link explaining the difference between using SPServices and CSOM which also includes both their PROS and CONS.

Maybe CAML builder uses RESTful webservices which might impact performance of your query and we all know that there are performance issues with javascript/jquery.

You might want to try converting to CSOM and check if it affects the performance of your code. Let me know if you need a sample code block and I'll gladly write one for you.

Upvotes: 0

Luis
Luis

Reputation: 6001

Not sure why in CAML builder your query is fast. Something that will speed up the query is to index the fields you are using to search:

http://msdn.microsoft.com/en-us/library/ff798465.aspx

Upvotes: 1

Related Questions