function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Prady01Prady01 

How to retrieving more than 10K records

I have page, Which inturn contains picklists like category when I select one category then the data related to that catogory must be displayed in the table.. Which is all working fine (page/class)but I am getting an error saying ,Too many query rows: 10001.. So can anyone, help me work around this problem...  

Best Answer chosen by Admin (Salesforce Developers) 
Pradeep_NavatarPradeep_Navatar

Use nested List to fetch more than 10K records :

 

            List<List<Account>> ListListAcc = New List<List<Account>>();

            List<Account> ListAcc;

 

            for(Integer i=0; i<5; i++)

            {

                        ListAcc = [Select id, name From Account limit 10000];

                        ListListAcc.add(ListAcc);

            }

 

            for(List<Account> ListA : ListListAcc)

            {

                        for(Account ac : ListA)

                        {

                                    // Display account records

                        }

            }

All Answers

Ispita_NavatarIspita_Navatar

The solution to your issue lies in using javascript API.

Pradeep_NavatarPradeep_Navatar

Use nested List to fetch more than 10K records :

 

            List<List<Account>> ListListAcc = New List<List<Account>>();

            List<Account> ListAcc;

 

            for(Integer i=0; i<5; i++)

            {

                        ListAcc = [Select id, name From Account limit 10000];

                        ListListAcc.add(ListAcc);

            }

 

            for(List<Account> ListA : ListListAcc)

            {

                        for(Account ac : ListA)

                        {

                                    // Display account records

                        }

            }

This was selected as the best answer
_Prasu__Prasu_

Hello Pradeep,

 

Will List doesnt support records over 1000, so query limit should be 1000 and not 10000? Am I right?

Pradeep_NavatarPradeep_Navatar

Limits on the number of items in a collection has been removed in Spring 10. However, there's still a general limit on heap size.

_Prasu__Prasu_

Thanks alot Pradeep!!

Amar Kumar 42Amar Kumar 42
Check the Latest Updated information on the Latest State and Central Government schemes at 
Sarkari Yojana (https://www.sarkariyojnaa.com/)
Vishal Mishra 25Vishal Mishra 25
Check the Latest Updated information on the Latest State and Central Government schemes at 
Sarkari Yojana https://sarkariyojanai.com/
Aman Naikya 6Aman Naikya 6
Check the Latest Updated information on the gaming & esports industry at Flizzyy.com
asdsg dffgasdsg dffg
Retrieving more than 10K records" can be a challenging task, but fear not, blue bay shepherd for sale (https://overallpets.com/blue-bay-shepherd-for-sale/)! There are efficient database optimization techniques and pagination methods that can help you manage large datasets seamlessly. Understanding your database system and utilizing the right tools will empower you to handle extensive records effortlessly. Happy data handling!