CAML Query for Large List.

Hi All,
I am having list in which there are more 60000 items in to it. Can you guys please help me out that what is the best practice to execute query on such large list ?
Is it a good way to increase thresold limit ? I don't think so. What else I can do ?
Any idea ? Please suggest.
Thanks in advance.

Hi Jaydeep,
I'hv updated my code as per your link described : but still its showing an error. Below I am pasting my source code.
Below is my code :
SPList list = spWeb.Lists.TryGetList("ListName");
SPQuery query = new SPQuery();
//query.QueryThrottleMode = SPQueryThrottleOption.Override;
query.Query = @"<Where>
<Eq>
<FieldRef Name='TCode' />
<Value Type='Text'>" + tcode + @"</Value>
</Eq>
</Where>";
query.ViewAttributes = "Scope=\"Recursive\"";
query.RowLimit = 200;
do
SPListItemCollection itemCollcetion = list.GetItems(query);
foreach (SPListItem item in itemCollcetion)
if (!tRoles.Contains(item["Title"].ToString()))
tRoles.Add(item["Title"].ToString());
query.ListItemCollectionPosition = itemCollcetion.ListItemCollectionPosition;
} while (query.ListItemCollectionPosition != null);
Limit it set to 10000 records and my list is having 13000 records.  Above code executes under run with elevated previliges.
Any suggestions ?
Thanks in advance.

Similar Messages

  • Caml query for filtering list item not working as expected in Sharepoint hosted app

    I am trying to filter list item based on particular value.
    var header = "xyz";
    camlQueryHeader.set_viewXml = "<view><Query><Where><Eq><FieldRef Name='Position'/>" + "<Value Type='Text'>" + header + "</Value></Eq></Where></Query></view>";
    Instead of getting filtered list items, I get all the list items. What am I missing?
    Note: I am creating Sharepoint hosted app using CSOM.
    regards, Ritesh Anand

    Hi,
    According to the code provided, I suggest you modify the code like this:
    camlQueryHeader.set_viewXml('<view><Query><Where><Eq><FieldRef Name=\'Position\'/>' + '<Value Type=\'Text\'>' + header + '</Value></Eq></Where></Query></view>');
    Here is a documentation of how to use the viewXml property of SP.CamlQuery object:
    SP.CamlQuery.viewXml Property
    Thanks
    Patrick Liang
    TechNet Community Support

  • CAML query performance for large lists

    I have a list with more than 10000 items. I am retrieving the items and displaying it in a RAD Grid on my page using CAML query. While retrieving the items, around 1000 records are retrieved due to filter. I have enabled paging in my grid and PageSize is
    set to 25. I have noticed that the load time of my page is very slow as it retrieves all the 1000 records at once.
    Is it possible to retrieve just 25 records for the first page on load. On click on the Next button or Page number it should retrieve the next set of 25 records for that particular page.
    I want to know if there is any way to link CAMl query paging with RAD grid paging
    Any code example would be greatly helpful.

    Hi,
    For pagination in SPListItem use the SPQuery.ListItemCollectionPosition property. 
    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spquery.listitemcollectionposition(v=office.15).aspx
    check the usefull urls
    http://omourad.blogspot.in/2009/07/paging-with-listitemcollectionposition.html
    http://www.anmolrehan-sharepointconsultant.com/2011/10/client-object-model-access-large-lists.html
    Anil

  • CAML query for more than two items in a list and bind those result to gridview?

    Hi Team,
    I am binding sharepoint 2013 list to gridview programatically.
    Now i need to search the results. If i gave some key word in text box and click on search.
    Then it should display only those values in gridview using caml query.
    Below is my form.

    Hi,
    Here is a blog about the CAML Query with Multiple Conditions for your reference:
    http://aasai-sharepoint.blogspot.com/2013/02/caml-query-with-multiple-conditions.html
    If you want to filter the list item, here is a web part from codeplex with the source code for your reference:
    SharePoint ListView Filter
    https://splistviewfilter.codeplex.com/
    Thanks,
    Dennis Guo
    TechNet Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Dennis Guo
    TechNet Community Support

  • CAML query on SharePoint list not working after reaching threshold limit

    I have written CAML query to filter and get list items. It was working fine, but the List items count crossed 5000 and its around 15000 items. In Server Object Model When i execute my query to get list items throws exception as " The
    attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator ".
    My Code:
    SPList list = web.Lists["ComplaintReturnsForm1"];
    string QIRIdNo = fldQIRIdNo.Text;
    SPQuery query = new SPQuery();
    query.Query = "<Where><Eq><FieldRef Name='fldQIRIdNo' /><Value Type='Text'>" + QIRIdNo + "</Value></Eq></Where>";
    SPListItemCollection itemcoll = list.GetItems(query);
    Please help me to fix it. 

    Hi Mario,
    Thanks a lot for your reply.
    query.Query = "<Where><Eq><FieldRef Name='fldQIRIdNo' /><Value Type='Text'>"
    + QIRIdNo + "
    in this CAML query i have indexed my field "fldQIRIdNo". Now i have more then 5000 items in list, and
    iam able to get my list item data without any error.
    Please let me know if my action is wrong.

  • Querying for large number of objects... searchspec limitation

    As part of a product i'm developing i may come across a scenario where i need to query for 100+ specific objects based on ids.
    I know the query input for WS 2.0 has a "searchspec" string field, but based on the sheer number of specific objects i need to query for i'm afraid the string may eventually get too large.
    Is there a way around this? Can i send multiple individual queries in a batch request? Can i add more than one search object to a single query page request? Anything?
    Thanks!
    -Kevin

    A few options available using the WS v2.0 Query methods:
    1. Use Arguments like page size and startrownumber arguments. This will allow you to specify the pagesize of the recordset to be returned and also the starting row number.
    2. The searchspec is a powerful argument and it supports a set of binary and unary operators. Refer the Ondemand user guide for a more complete set of operators supported by searchspec. To narrow the results of your query, you could use the "AND" operator between 2 or more fields in your object query.
    Hope this helps.
    Jaya

  • Query for price list

    Experts,
    Can you please tell me what will be the query for
    for all prices which are u201C0u201D empty  (products)
    Thanks a lot in advance

    Thanks a lot Rahul and Gordon
    I am trying like as per the need
    SELECT T0.ItemCode, T0.ItemName, T0.ItmsGrpCod, T2.ListNum, T2.ListName,
    Sum (T1.[Price]) FROM OITM T0 INNER JOIN ITM1 T1 ON T0.ItemCode = T1.ItemCode INNER
    JOIN OPLN T2 ON T1.PriceList = T2.ListNum GROUP BY  T0.[ItemCode] HAVING Sum (T1.[Price]) <=0
    But error comes like
    1). [Microsoft][SQL Native Client][SQL Server]Column 'OITM.ItemCode' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. 2). [Microsoft][SQL Native Client][SQL Server]Statement 'Received Alerts' (OAIB) (s) could not be prepared.
    Please Help

  • Java library for large list sorts in small amount of memory

    Hi All
    Wondering whether anybody would know of a ready made java library for sorting large lists of objects. We will write ourselves if necessary but I'm hoping this is the sort of problem that has been solved a million times and may hopefully have been wrapped behind some nice interface
    What we need to do is something along the line of:
    Load a large list with objects (duh!)
    If that list fits into an allowed amount of memory great. Sort it and end of story.
    If it won't then have some mechanism for spilling over onto disk and perform the best sort algorithm possible given some spill over onto disk.
    These sorts need to be used in scenarios such as a random selection of 10% of the records in a 100G unsorted file and delivered sorted, with the jobs doing the sorts being limited to as little as 64MB of memory (these are extremes but ones that happen quite regularly).
    Some of you might think "just use a database". Been there. Done that. And for reasons beyond the scope of this post its a no goer.
    Thanking you for all your help in advance.

    Of course this kind of sorting was common back in days of yore when we had mainframes with less than 1MB or ram.
    The classic algorithm uses serveral files.
    1) Load as much as will fit
    2) sort it
    3) Write it to a temporary file
    4) Repeat from 1, altnerating output between two or three temp files.
    Your temporary files then each contain a series of sorted sequences (try saying that three times fast).
    You then merge these sequences into longer sequences, creating more temp files. Then merge the longer sequences into even longer ones, and so on until you're left with just the one sequence.
    Merging doesn't require any significant memory use however long the sequences. You only need to hold one record from each temp file being merged.

  • SQL query for Menu list for a responsibility

    Dear All
    I want a Query to extract all menu prompt for a responsibility like
    Responsibility -------------------------- menu with prompt
    System Administrator-------------------------- Concurrent\Requests
    System Administrator-------------------------- Concurrent\Set
    System Administrator-------------------------- Concurrent\Conflicts Domains
    System Administrator-------------------------- Concurrent\Manager\Administer
    System Administrator-------------------------- Concurrent\Manager\Define
    System Administrator-------------------------- Concurrent\Manager\WorkShifts
    System Administrator-------------------------- Concurrent\Manager\Rule
    System Administrator-------------------------- Concurrent\Program\Define
    System Administrator-------------------------- Concurrent\Program\Executable
    System Administrator-------------------------- Concurrent\Program\Types
    System Administrator-------------------------- Profile\System
    System Administrator-------------------------- Profile\Personal
    list should be in order which is defined in apps menu.
    I will be great thankful you all.
    Regards
    Aamir

    I did not realize that the procedure has bugs. Sorry about that.
    It took some time to figure out but once fixed, the script works properly.
    I can't post the full code (due to Metalink restrictions) but here are the fixes I had to do.
    1) Do not cut and paste the whole code. It does not get formatted properly. Do small sections at a time.
    2) Change the quotes around the "STACK OVERFLOW". They are not proper.
    3) The code needs labels for the goto statements to work. Replace the first <> with <<label_outer>>. Replace the second <> with <<label_inner>>
    Sandeep Gandhi

  • Query for the list of publich holidays from the Project Server 2010 for reporting

    I would like to get the list of public holidays that is configured in the calendar from the reporting database. I am not sure if this information is available in the database.
    Please can you provide with the sql query . thanks
    Simi

    I just put together this query based on what Elli J did. My problem was to come up with a way to define a calendar-based "grace period" extension of the baseline finish date for a project. The grace period had to be based on a scale factor (here 1.1) applied
    to the project's official baseline duration. I then had to project forward, using the standard calendar, to the relevant grace period finish date on a per-project basis.
    Anyway, here is what I came up with. Note that I eliminated the SUM operations as unnecessary, and I also had to account for the fact that the official calendar days queryable using resource by day base capacity can "run out" before it should, so that it
    has to be extended by tacking on regular weekdays after that.
    SELECT
        P.ProjectUID,
        P.ProjectName,
        ProjectBaseline0StartDate = PSTB0.TaskBaselineStartDate,
        ProjectBaseline0FinishDate = PSTB0.TaskBaselineFinishDate,
        ProjectBaseline0DurationInDays = ROUND(PSTB0.TaskBaselineDuration / 8, 0),
        ProjectBaseline0GracePeriodDurationInDays = ROUND(ROUND(PSTB0.TaskBaselineDuration / 8, 0) * (GracePeriodParameters.MultiplierExcludingBase), 0),
        ProjectBaseline0GracePeriodFinishDate =
            SELECT TimeByDay
            FROM
                 SELECT
                     TimeByDay,
                     DayRank = RANK() OVER (ORDER BY TimeByDay)
                 FROM
                    -- Query all calendar days in standard calendar, using resource base capacity as proxy
                    -- Actual calendar data is not available in any of the MSPS relational databases.
                     SELECT TBD.TimeByDay
                     FROM dbo.MSP_TimeByDay TBD
                     JOIN dbo.MSP_EpmResourceByDay RBD ON TBD.TimeByDay = RBD.TimeByDay
                     JOIN dbo.MSP_EpmResource R ON R.ResourceUID = RBD.ResourceUID
                     WHERE
                        R.ResourceBaseCalendar = StandardCalendarInformation.CalendarName AND
                        TBD.TimeByDay > PSTB0.TaskBaselineFinishDate AND
                        RBD.BaseCapacity > 0
                    UNION
                    -- Extend genericallly with weekdays if the calendar days queried above run out too early
                    SELECT TBD2.TimeByDay
                    FROM dbo.MSP_TimeByDay TBD2
                    WHERE
                        TBD2.TimeDayOfTheWeek IN (2,3,4,5,6) AND
                        TBD2.TimeByDay > PSTB0.TaskBaselineFinishDate AND
                        TBD2.TimeByDay > StandardCalendarInformation.LatestDateWithNonZeroCapacity
                UnrankedUnion
            RankedUnion
            WHERE RankedUnion.DayRank = ROUND(ROUND(PSTB0.TaskBaselineDuration / 8, 0) * (GracePeriodParameters.MultiplierExcludingBase), 0)
    FROM dbo.MSP_EpmProject P
    LEFT JOIN dbo.MSP_EpmTask PST ON PST.TaskIsProjectSummary = 1 AND P.ProjectUID = PST.ProjectUID
    LEFT JOIN dbo.MSP_EpmTaskBaseline PSTB0 ON PSTB0.BaselineNumber = 0 AND PST.TaskUID = PSTB0.TaskUID
    CROSS JOIN (SELECT 1.1 AS MultiplierIncludingBase, 0.1 AS MultiplierExcludingBase) GracePeriodParameters
    CROSS JOIN
        SELECT TOP 1 CalendarName = C.CAL_NAME, LatestDateWithNonZeroCapacity = TBD.TimeByDay
        FROM dbo.MSP_TimeByDay TBD
        JOIN dbo.MSP_EpmResourceByDay RBD ON TBD.TimeByDay = RBD.TimeByDay
        JOIN dbo.MSP_EpmResource R ON R.ResourceUID = RBD.ResourceUID
        JOIN [Demo2010A_PWA_Published].dbo.MSP_CALENDARS C ON R.ResourceBaseCalendar = C.CAL_NAME
        WHERE C.CAL_IS_STANDARD_CAL = 1 AND RBD.BaseCapacity > 0
        ORDER BY TBD.TimeByDay DESC
    StandardCalendarInformation
    - William Schmidt

  • Query for Price List changes

    Hi,
    I need a query to get a listing of all sales orders where the pricing has been changed from the approved price list.
    Also, a query to pull a list of changes to price tables that occurred in February, March, and June months of 2007.
    Can anyone help me with this?
    thanks,
    Ashwathy

    Hi,
    I agree with you, possible but not probable. In pricing, you can have prices for all items, for categories and for items. You can also have prices defined for a range of quantities in a UOM. Assuming your prices are defined in the list for items, in the same UOM product was ordered, the query would be like that for one order:
    select c.ordered_item, c.unit_list_price, c.unit_selling_price, a.operand
    from qp_list_lines a,
    qp_pricing_attributes b,
    oe_order_lines_all c
    where a.list_line_id = b.list_line_id
    and a.list_line_type_code = 'PLL'
    and b.product_attribute_context = 'ITEM'
    and b.product_attribute = 'PRICING_ATTRIBUTE1'
    and c.inventory_item_id = b.product_attr_value
    and c.pricing_quantity_uom = b.product_uom_code
    and a.arithmetic_operator = 'UNIT_PRICE'
    and c.header_id = :header_id
    and c.price_list_id = a.list_header_id
    and c.pricing_date between nvl(a.start_date_active,c.pricing_date)
    and nvl(a.end_date_active,c.pricing_date)
    Hope it helps,
    Ketter Ohnes

  • Query For Large Amount of Data

    Hello All,
    I apologize in advance if I am not posting this in the right section. I am fairly new to APEX and database designing. My goal is to create an inquiry screen for a database of people.
    I am running APEX 4.2 on 11g. The information is store in 3 tables; Names, Demographics, Address. Each table had a PIN ID column that ties them all together. Each table has almost a million rows in them.
    Currently I have it set up that the person types in the name they want to search and it gets passed into a hidden page item on the next page where there is a report with a select statement based on the page item. Everything works right now however it is slow. I am having a 5-10 second delay before the results come up.
    My question is, is there a better way to set up these tables. What is the best way to make this faster?
    I'm sorry if this is a vague question but any help, or point in the right direction will be greatly appreciated
    Thank You !

    976533 wrote:
    Hello All,Welcome to the forum: please read the FAQ and forum sticky threads (if you haven't done so already), and update your forum profile with a real handle instead of "976533".
    When you have a problem you'll get a faster, more effective response by including as much relevant information as possible upfront. This should include:
    <li>Full APEX version
    <li>Full DB/version/edition/host OS
    <li>Web server architecture (EPG, OHS or APEX listener/host OS)
    <li>Browser(s) and version(s) used
    <li>Theme
    <li>Template(s)
    <li>Region/item type(s) (making particular distinction as to whether a "report" is a standard report, an interactive report, or in fact an "updateable report" (i.e. a tabular form)
    With APEX we're also fortunate to have a great resource in apex.oracle.com where we can reproduce and share problems. Reproducing things there is the best way to troubleshoot most issues, especially those relating to layout and visual formatting. If you expect a detailed answer then it's appropriate for you to take on a significant part of the effort by getting as far as possible with an example of the problem on apex.oracle.com before asking for assistance with specific issues, which we can then see at first hand.
    I apologize in advance if I am not posting this in the right section. I am fairly new to APEX and database designing. My goal is to create an inquiry screen for a database of people.It might be more appropriate to the {forum:id=75} forum, so you should look at the following entries on their FAQ as well:
    <li>{message:id=9360002}
    <li>{message:id=9360003}
    I am running APEX 4.2 on 11g. The information is store in 3 tables; Names, Demographics, Address. Each table had a PIN ID column that ties them all together. Each table has almost a million rows in them.
    Currently I have it set up that the person types in the name they want to search and it gets passed into a hidden page item on the next page where there is a report with a select statement based on the page item. Everything works right now however it is slow. I am having a 5-10 second delay before the results come up.
    My question is, is there a better way to set up these tables. What is the best way to make this faster? Are there suitable indexes on the tables?
    Does the report query use them?
    As described above, either: reproduce the problem on apex.oracle.com; or post DDL to allow us to recreate the tables and indexes, and the SQL from your report.

  • Creating a query for task list operations

    hello all
    I checked the forum for similar questions but could not find any.
    I am trying to create a task list for the following:
    1) specific plant
    2) generic task list
    3) specific group counter
    4) specific operations type (filtered by control keys)
    in the display I also include the dependencies of the operations.
    I also need to link the task list to a specific class and extract the characteristics value from the class, based on the task list (I think this is better with infoset: if so, in a second stage).
    I am using tables
    1)PLKO and PLPO joined by PLNTY and PLNNR
    2) CUOB, joined to PLPO by KNOBJ and CUKB joined to CUOB by KNNUMfor the dependencies
    the results tho, gave me operations that did not exist in the task list so I discovered that there were change masters to the task lists and I added table AENR, outer joined to PLKO by AENNR where I excluded inactive changes.
    I still do not get correct results.
    I do not get all the active change masters related to a task list, I do not manage to get the task list without changes and also the related operations and dependencies are not correct.
    can someone help?

    Hi alisa,
    Onethng was not yet touched upon in the discussion sofar. If you are not getting all the records those should come, then you need to try LEFT OUTER JOIN  between tables by trial. (Trial means LOJ is not accepted on adjacent tables.) I hope you know that the default connection between fields of 2 tables in through INNER JOIN.  You need to right click on this line and select LOJ for making it LOJ. This brings you all the records which are being filtered due to IJ (if any).
    Try this, if you haven't done already.
    KJogeswaraRao

  • Improving SQL query for large records.

    I need to extract the difference on the table t1 and t2(contains both almost 6M records). Im looking specifically on the two columns (c1,c2)for my comparison.I need also to look at reference table to extract also other fields for my report. thank you
    Dynamic Table (same table and structure but different records.)
    t1
    t2
    Reference Static Table (all the tables below have two columns. c1 and c2 used for reference only)
    t3
    t4
    t5
    --Extracting data in t1 but not exists in t2
    WITH v1 AS(SELECT c2,c3,c4 FROM t1 at1
    WHERE NOT EXISTS (SELECT 'x' FROM t2 at2 WHERE at1.c1 = at2.c2)),
    v2 AS (SELECT c1, c2 FROM t3),
    v3 AS (SELECT c1, c2, c3 FROM t4),
    v4 AS (SELECT c1,c2 FROM t5)
    SELECT v1.c1, v1.c2, v3.c2, v4.c2 FROM t,t2,t3,t4
    WHERE v1.c1 = v2.c1
    AND v2.c2 = v3.c1
    AND v3.c2 = v4.c1
    ORDER BY v1.c1
    I'm trying to improve my scripts to generate the record as fast as possible coz it takes too long. Any suggestions guys.? Im trying to look also on explain plan but I'm new on this. thank you

    Hi,
    your sample code can not compile?
    There is no column c1 in the v1?
    Probably a typo anyway :)
    A couple of remarks:
    The way you've used v1, v2, v3 and v4 does not help performance.
    It only helps increasing the confusion.
    Rewrite the query without the WITH clause, post the execution plan for the query and report your Oracle version and we can help you further.
    / Ronnie

  • Query for a list of FIFO layers with quantity and FIFO cost

    Hi,
    Is there a report/ query where I could get something as follows:
    ItemCode1 - Open FIFO Layer1 - Quantity 1 - Open FIFO Layer1 Cost - Open FIFO Layer1 Inventory Value
    ItemCode1 - Open FIFO Layer2 - Quantity 2 - Open FIFO Layer2 Cost - Open FIFO Layer2 Inventory Value
    ItemCode1 - Open FIFO Layer3 - Quantity 3 - Open FIFO Layer3 Cost - Open FIFO Layer3 Inventory Value
    The total quantity and the total value of this would match the total quantity and total value of the Inventory Audit Report.
    I know OINM table has all detailed transactions, but I find it difficult to get what I want from OINM.
    Thanks,
    Ajay Audich

    Hi Ajay.....
    Please do refer Inventory Valuation Simulation Report for FIFO Method. It gives you the details as you required........
    Regards,
    Rahul

Maybe you are looking for