+ Start a Discussion
Sridhar VenkateswaraluSridhar Venkateswaralu 

Collection Size Limit at Runtime

Hi ,

 

I am facing an issue with displaying the  list of records(more than 10000), it gives out an exception saying Collection Size 1001 exceeds limit of 1000. I Request you to lease do post in if you have a solution for this.

 

Thanks in Advance

 

Sridhar

bob_buzzardbob_buzzard
sam_Adminsam_Admin

Bob,

  I went through that thread modified my code but am still getting  Collection size 1,001 exceeds maximum size of 1,000, intially i got Collection size 4,567 exceeds maximum size of 1,000 but later when i modified it got reduced but still not enough to get result, what am doing wrong ?

 

Here is my VF and class

<apex:page controller="thousandLimit">    
   <apex:pageBlock >
      <apex:repeat value="{!thousandBlocks}" var="block">
            <apex:pageBlockTable value="{!block.cases}" var="c">
            <apex:column value="{!c.CaseNumber}"/>
            <apex:column value="{!c.owner.name}"/>
            <apex:column value="{!c.App_Process__c}"/>
            <apex:column value="{!c.Load__c}"/>
            <apex:column value="{!c.subject}"/>
            <apex:column value="{!c.Estimated_Completion_Date__c}"/>   
            <apex:column value="{!c.Complete__c}"/>
            <apex:column value="{!c.Priority}"/>
            <apex:column value="{!c.Case_Age_Days__c}"/>                    
            </apex:pageBlockTable>
        </apex:repeat>
     </apex:pageBlock>  
</apex:page>

 

 

public class thousandLimit
{
    private limitWrapper[] thousandBlocks = new limitWrapper[]{};
    
    private final integer listLimit;
    
    public thousandLimit()
    {
        listLimit = 1000;
    }
    
    public limitWrapper[] getthousandBlocks()
    {
        thousandBlocks = new limitWrapper[]{};
        
        integer counter = 0;
        integer loopCount = 0;
        case[] tmpcase = new case[]{};
        
        for(case c:[select CaseNumber,owner.name,App_Process__c,Load__c,subject,Estimated_Completion_Date__c,Complete__c,Priority,Case_Age_Days__c from Case
                where (Status != 'Closed' or Status != 'Declined') and Estimated_Completion_Date__c = null and owner.Alias like 'EA%' order by owner.name])
        {
            if(counter < listLimit)
            {
                tmpcase.add(c);
                counter++;
            }
            else
            {
                loopCount++;
                thousandBlocks.add(new limitWrapper(tmpcase,loopCount));
                tmpcase = new case[]{};
                tmpcase.add(c);
                counter = 0;
            }            
        }
        
        if(thousandBlocks.size() == 0)
        {
            loopCount++;
            thousandBlocks.add(new limitWrapper(tmpcase,loopCount));
        }
        
        return thousandBlocks;
    }
    
    public class limitWrapper
    {
        public case [] cases {get;set;}
        public integer blockNumber {get;set;}
        public limitWrapper(case[] accs, integer i)
        {
            cases = accs;
            blockNumber = i;
        }
        
    }
}

sam_Adminsam_Admin

i solved this by reducing listlimit to 999    listLimit = 999;

Teach_me_howTeach_me_how

Question: you solve the issue by limiting the record to 999. my question is what happen to  your 1000th record. (does it will not show anymore? is the 1000th record is not important to you to display it?)

sam_Adminsam_Admin

If i limit it to 999 then it displays all records and it's not record size , i just have 180 records.

bob_buzzardbob_buzzard

If you only have 180 records, that implies you have some duplication in there - is that the case?

 

If not, can you explain a bit more about what you are actually trying to do?

Sridhar VenkateswaraluSridhar Venkateswaralu

HI All,

 

Thanks for the quich response, :smileyhappy:

 

The actual requirement we have is to display some where around 15000-20000 records on to the Visual force with pagination of 10 records per page. now the concern that we have is that, whenever we try to increase the record size limit to over 10,000, we are getting collection size exception and sometimes even Heap Size exception

  • In this case, will queryLocator be of any help in getting the records and displaying on to the visual force page??Does using of Query locator solve heap size issue.
  • what is the limit for Querylocator  Rows retreived.??
  • one more concern is when we are limiting the records to  below 10,000 also,  the data loaded on to the visual force is taking too much time. (data is queried through a soql and put into a list and is then displayed on to the visual force using <apex:repeat>  )?? any suggestions to improve page performance.

 

waiting for your suggestions.

sam_Adminsam_Admin

I want to display 4 visual force pages onto one page,so i created 5th one by making frames of all 4 and i was able to display it , but my concern is can these all 4 VF can be driven just by selecting owner from top, in other words if i select a user from dropdown then it should only display records on these 4VF belonging to that specific owner

bob_buzzardbob_buzzard

We seem to have a couple of cross threads going on here.  To answer the OPs question, as far as I'm aware the query locator will still limit you to 10000 records.  The volume of records that you are referring to is quite large - are the users really going to page through 15k records 10 at a time?  I'd suggest that you give them a way to filter the records returned in some way.  

Sridhar VenkateswaraluSridhar Venkateswaralu

Thanks Bob. :smileyhappy:

 

does using database.querylocator instead of normal database.query help in loading the records faster?? I mean does it by any way help in improving the user experience (mean page performance)

 

waiting for your reply.

 

Thanks,

Sridhar

 

 

 

bob_buzzardbob_buzzard

That's a good question.  The docs recommend using a QueryLocator when the records can be queried via SOQL, but that looks to be much more in the context of batch apex than Visualforce.  I haven't found any best practice advice from Salesforce on this I'm afraid.