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
RArunrajRArunraj 

Count of more than 50,000 Records

Hi,

 

I need to count the TOTAL Record of Account Object using SOQL and display the record count in the Visualforce page, I am already having more than 50,000 records. How can I get the record count and display the total record count in VF Page? Is there is any other way to get the count in Vf page?

 

Thanks,

Arunraj

Bramha1Bramha1

Integer ab = [Select count() from Account ];

 

Use this integer in VF Page .

 

 

 

 

Cheers

 

Bramha

Ankit AroraAnkit Arora

Dam!! How can i missed that,

 

Here is the code :

 

List<AggregateResult> ag = [select count(id) total from account ] ;
System.debug(' :::: ' + ag[0].get('total')) ;

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

RArunrajRArunraj

I am getting the following error "System.LimitException: Too many query rows: 50001?" , when the record count is more than 50000, so what i need to do to get the exact record count in VF Page(When it is more than 50,000). 

 

Thanks,

Arunraj

David81David81

Unfortunately, the aggregate functions are still crippled by the standard SOQL query limits on the number of records retrieved. Even though you are really only bringing back one "row" of data, you are still dinged for every record that makes up that count.

 

See the note on this page of the Apex docs.

 

http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/langCon_apex_SOQL_agg_fns.htm?SearchType=Stem

Sonu Sharma.ax1610Sonu Sharma.ax1610

 

Hi,

 

I am also getting the same error.

 

I would like to count number of records over 50k but i am getting "System.LimitException: Too many query rows: 50001".

 

Can any one provide some suggestion to count number of records

 

Regards

Sonu Sharma

 

 

Nishant sinhaNishant sinha

If you only want to display the count, thne you can use @Readonly annotation.

Sowjanya VaddiSowjanya Vaddi
Too many query rows: 50001--I place LIMIT but still same error,Please suggest to resolve this