---
schema_version: "1"
id: 31d11b77813e7c64f88112159f97dc4045a3d6ef30473c6c5c0355b8985974ba
title: Setting Read-Only Mode for an Entire Page
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/salesforce-pages-developers-guide/guides/pages/controller/pages-controller-readonly-context-pagelevel.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-pages-developers-guide/guide/pages-controller-readonly-context-pagelevel.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 343068da12b9d8c928c365746b098e4cc583368d043556d723c0af98f817f8c0
products:
  - Visualforce Developer Guide
  - Platform Developer Content
---

# Setting Read-Only Mode for an Entire Page

To enable read-only mode for an entire page, set the `readOnly` attribute on the `<apex:page>` component to `true`.

For example, here’s a simple page that is processed in enable read-only mode:

<!-- otherprops: apex_page -->
```markup
<apex:page controller="SummaryStatsController" readOnly="true">
    <p>Here is a statistic: {!veryLargeSummaryStat}</p>
</apex:page>
```

The controller for this page is also simple, but illustrates how you can calculate summary statistics for display on a page:

<!-- otherprops: apex_code -->
```controller
public class SummaryStatsController {
    public Integer getVeryLargeSummaryStat() {
        Integer closedOpportunityStats = 
            [SELECT COUNT() FROM Opportunity WHERE Opportunity.IsClosed = true];
        return closedOpportunityStats;
    }
}
```

Normally, queries for a single Visualforce page request may not retrieve more than 50,000 rows. In enable read-only mode, this limit is relaxed to allow querying up to 1,000,000 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. Here’s a simple controller and page demonstration:

<!-- otherprops: apex_code -->
```controller
public class MerchandiseController {

    public List<Merchandise__c> getAllMerchandise() {
        List<Merchandise__c> theMerchandise = 
            [SELECT Name, Price__c FROM Merchandise__c LIMIT 10000];
        return(theMerchandise);
    }
}
```

<!-- otherprops: apex_page -->
```markup
<apex:page controller="MerchandiseController" readOnly="true">
    <p>Here is all the merchandise we have:</p>
    <apex:dataTable value="{!AllMerchandise}" var="product">
        <apex:column>
            <apex:facet name="header">Product</apex:facet>
            <apex:outputText value="{!product.Name}" />
        </apex:column>
        <apex:column>
            <apex:facet name="header">Price</apex:facet>
            <apex:outputText value="{!product.Price__c}" />
        </apex:column>
    </apex:dataTable>
</apex:page>
```

While Visualforce pages that use enable read-only mode for the entire page can’t use data manipulation language (DML) operations, they can call getter, setter, and action methods that affect form and other user interface elements on the page, make additional read-only queries, and so on.

