1

I have object A which has 2 Lakh records. A child has to be created under each of these records on a click of a button and show them on a vf page. I am hitting a lot of limitations like

1) 50001 records retrieved per query error. 2) View state error. 3) Heap size error for the lists used(A single list of child is needed for further transaction).

How can I show all the 2 lakh records on the vf page without these errors at one execution?

2
  • 1
    50k records is an API limit. You'll want to put a limit on your SOQL query or use pagination in your controller. See the VF Workbook, Apex Dev Guide and SOQL and SOSL Reference for more on this. In essence, it's not possible to do this in one execution because of API limits.
    – crmprogdev
    Oct 6, 2014 at 13:45
  • And perhaps use batch apex to create the child records.
    – Dominic
    Oct 6, 2014 at 13:46

2 Answers 2

1

50k records is an API limit. You'll want to put a limit on your SOQL query or use pagination in your controller. See the VF Workbook, Apex Dev Guide and SOQL and SOSL Reference for more on this. In essence, it's not possible to do this in one execution because of API limits.

1

One problem with using pagination as suggested by @crmprogdev is that the OFFSET maximum value is 2000 so the greatest number of records you could query in this way would be 52,000. Far short of the 2 Lahk (200,000) records desired.

Seems like you'll need to figure out another way of processing these records. Batch apex sounds like it's what you want at least for creating the child records.

For showing all 200,000 records on your Visualforce page look into the @ReadOnly annotation.

Normally, queries for a single Visualforce page request may not retrieve more than 50,000 rows. In read-only mode, this limit is relaxed to allow querying up to 1 million rows.

In addition to querying many more rows, the readOnly attribute also increases the maximum number of items in a collection that can be iterated over using components such as apex:dataTable, apex:dataList, and apex:repeat. This limit increased from 1,000 items to 10,000

I'm not sure how this might affect the OFFSET functionality, but you should at least be able to query the information you want. If the OFFSET functionality can't be used then you'll have to figure out a scheme for iterating through the list that is returned and displaying it on the page.

Some information can be found here and here.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .