### Apache Airflow version

2.5.2

### What happened

when trying to delete a dag run with many tasks (>1000) the operation times out and the dag run is not deleted. 

### What you think should happen instead

_No response_

### How to reproduce

attempt to delete a dag run that contains >1000 tasks (in my case 10k) using the dagrun/list/ page results in a timeout:
![image](https://user-images.githubusercontent.com/7373236/226325567-5a87efa1-4744-417e-9995-b97dd1791401.png)


code for dag (however it fails on any dag with > 1000 tasks):
```
import json

from airflow.providers.cncf.kubernetes.operators.kubernetes_pod import KubernetesPodOperator
from datetime import datetime, timedelta
from airflow.decorators import dag, task

default_args = {
    'owner': 'airflow',
    'depends_on_past': False,
    'retries': 0,
    'retry_delay': timedelta(minutes=1),
    'start_date': datetime(2023, 2, 26),
    'is_delete_operator_pod': True,
    'get_logs': True
}


@dag('system_test', schedule=None, default_args=default_args, catchup=False, tags=['maintenance'])
def run_test_airflow():
    stress_image = 'dockerhub.prod.evogene.host/progrium/stress'  

    @task
    def create_cmds():
        commands = []
        for i in range(10000):
            commands.append(["stress --cpu 4 --io 1 --vm 2 --vm-bytes 6000M --timeout 60s"])
        return commands

    KubernetesPodOperator.partial(
        image=stress_image ,
        task_id=f'test_airflow',
        name=f'test_airflow',
        cmds=["/bin/sh", "-c"],
        log_events_on_failure=True,
        pod_template_file=f'/opt/airflow/dags/repo/templates/cpb_cpu_4_mem_16'
    ).expand(arguments=create_cmds())


run_test_airflow()

```

### Operating System

kubernetes deployment

### 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)

num_of_all_dags = status_count_paused
            else:
                current_dags = all_dags
                num_of_all_dags = all_dags_count
            sort_column = DagModel.__table__.c.get(arg_sorting_key)
            if sort_column is not None:
                if arg_sorting_direction == "desc":
                    sort_column = sort_column.desc()
                current_dags = current_dags.order_by(sort_column)
            dags = current_dags.options(joinedload(DagModel.tags)).offset(start).limit(dags_per_page).all()
            user_permissions = g.user.perms
            can_create_dag_run = (
                permissions.ACTION_CAN_CREATE,
                permissions.RESOURCE_DAG_RUN,
            ) in user_permissions
            dataset_triggered_dag_ids = {dag.dag_id for dag in dags if dag.schedule_interval == "Dataset"}
            if dataset_triggered_dag_ids:
                dataset_triggered_next_run_info = get_dataset_triggered_next_run_info(
                    dataset_triggered_dag_ids, session=session
                )
            else:
                dataset_triggered_next_run_info = {}
            for dag in dags:
                dag.can_edit = get_airflow_app().appbuilder.sm.can_edit_dag(dag.dag_id, g.user)
                dag.can_trigger = dag.can_edit and can_create_dag_run
                dag.can_delete = get_airflow_app().appbuilder.sm.can_delete_dag(dag.dag_id, g.user)
            dagtags = session.query(func.distinct(DagTag.name)).all()
            tags = [
                {"name": name, "selected": bool(arg_tags_filter and name in arg_tags_filter)}
                for name, in dagtags