### Apache Airflow version

2.5.0

### What happened

We're currently running a suboptimal setup where database connectivity is laggy, 125ms roundtrip.

This has interesting consequences. For example, `airflow roles list` is really slow. Turns out that it's doing a lot of individual queries.

### What you think should happen instead

Ideally, listing roles should be a single (perhaps complex) query.

### How to reproduce

We're using py-spy to sample program execution:

```bash
$ py-spy record -o spy.svg -i --rate 250 --nonblocking airflow roles list
```
Now, to see the bad behavior, the database should incur significant latency.

### Operating System

Linux

### Versions of Apache Airflow Providers

_No response_

### Deployment

Official Apache Airflow Helm Chart

### Deployment details

_No response_

### Anything else

_No response_

### Are you willing to submit PR?

- [ ] Yes I am willing to submit a PR!

### Code of Conduct

- [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)

for baseview in self.baseviews:
            if baseview.__class__ == view.__class__:
                return True
        return False
    def _process_inner_views(self):
        for view in self.baseviews:
            for inner_class in view.get_uninit_inner_views():
                for v in self.baseviews:
                    if isinstance(v, inner_class) and v not in view.get_init_inner_views():
                        view.get_init_inner_views().append(v)
def init_appbuilder(app):
    """Init `Flask App Builder <https://flask-appbuilder.readthedocs.io/en/latest/>`__."""
    from airflow.www.security import AirflowSecurityManager
    security_manager_class = app.config.get("SECURITY_MANAGER_CLASS") or AirflowSecurityManager
    if not issubclass(security_manager_class, AirflowSecurityManager):
        raise Exception(
            """Your CUSTOM_SECURITY_MANAGER must now extend AirflowSecurityManager,
             not FAB's security manager."""
        )
    AirflowAppBuilder(
        app=app,
        session=settings.Session,
        security_manager_class=security_manager_class,
        base_template="airflow/main.html",
        update_perms=conf.getboolean("webserver", "UPDATE_FAB_PERMS"),
    )