# Override the count route

This example shows you how to override the count default route.\
\
Forest Admin comes packaged with a set of existing routes, which execute Forest Admin's default logic. At installation, they are generated in `/routes`**.**&#x20;

![](/files/-M3zA85jjj2-fx8K7K5A)

## Requirements

* An admin backend running on forest-express-sequelize

## How it works

### Directory: /routes

This directory contains the `users.js` files where the routes are declared.

Forest Admin API is generating a default count query to manage the display and pagination of your data. To override the count route, simply remove the `next()` statement and add your own logic.

The solution is to **override this default query** using [an approximative count](https://wiki.postgresql.org/wiki/Count_estimate). If you don't need an exact count, it will be much faster to retrieve the data for your big tables:

{% code title="/routes/users.js" %}

```javascript
//...

// Define an optimized count using reltuples
const countOptimized = async (request, response, next) => {
  try {
    const noFilterOrSearch = !request.query.search && !request.query.filter;
    if (noFilterOrSearch) {
      const result = await models.sequelize
        .query("SELECT reltuples AS count FROM pg_class WHERE relname = 'users';");
      const { count } = result[0][0];
      response.send({ count });
    } else {
      next();
    }
  } catch (error) {
    next(error);
  }
};

// Send back the optimized count in the default count route
router.get('/users/count', ensureAuthenticated, permissionMiddlewareCreator.list(), countOptimized);

//...
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.forestadmin.com/woodshop/how-tos/override-the-count-route.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
