Documentation » Admin

12. Virtual Field Descriptions »

« 10. Overwrite Admin Configuration

11. Improve performance of large datasets

If your database table contains thousands of records, the database queries generated by SonataAdmin may become very slow. Here are tips how to improve the performance of your admin.

11.1. Change default Pager to SimplePager

Default Pager is counting all rows in the table, so user can easily navigate to any page in the Datagrid. But counting thousands or millions of records can be slow operation. If you don’t need to know the number of all records, you can use SimplePager instead. It doesn’t count all rows, but gives user only information if there is next page or not.

To use SimplePager in your admin just define pager_type inside the service definition:

  • XML
    <!-- src/AppBundle/Resources/config/admin.xml -->
    <service id="" class="AppBundle\Admin\PostAdmin">
        <tag name="sonata.admin" manager_type="orm" group="Content" label="Post" pager_type="simple" />
        <argument />
        <argument />
  • YAML
    # src/AppBundle/Resources/config/admin.yml
            class: AppBundle\Admin\PostAdmin
                - { name: sonata.admin, manager_type: orm, group: "Content", label: "Post", pager_type: "simple" }
                - ~
                - AppBundle\Entity\Post
                - ~
            public: true


The pager_results template is automatically changed to @SonataAdmin/Pager/simple_pager_results.html.twig if it’s not already overloaded.

Found a typo? Something is wrong in this documentation? Just fork and edit it!