I ran into a legacy custom visualforce page at a client that was getting the error “Too many query rows: 50001”. After some quick googling I found that in the Winter 12 release, Salesforce added two features that can help you.

@ReadOnly Annotation

Visualforce controller methods with the @ReadOnly annotation automatically take advantage of read-only mode. However, restrictions on the @ReadOnly annotation means that, for Visualforce controller methods, a read-only method must also have the @RemoteAction annotation. The @RemoteAction annotation requires that the method be:

  • Either global or public
  • static


Visualforce ReadOnly Attribute

<apex:page controller="SummaryStatsController" readOnly="true">
<p>Here is a statistic: {!veryLargeSummaryStat}</p>


This allows either a single WebService, RemoteAction, or Schedulable.execute() method or the entire visualforce page to execute read only SOQL queries. By doing this you raise the limit from 50,000 records to 1 million.

The great thing about this is it should increase the speed and performance of the queries and you can build custom reports with more data. In fact, I would suggest that if you have a page that deals with a decent amount of records and does not need to insert, update or delete data, that you consider using this feature.