FrankYang0529 opened a new pull request, #73021:
URL: https://github.com/apache/airflow/pull/73021
## Why
- `GET /eventLogs` and `GET /eventLogs/{event_log_id}` use only
`dag_display_name` and `task_display_name` from the joined Dag and task
instance, but the query selected every column of both tables.
- `TaskInstance.dag_run` is `lazy="joined"`, so the query also joined
`dag_run` and selected all of its columns. Nothing in the response reads them.
## How
- Load only `dag_display_name` from `dag`, and only `task_display_name` and
`task_id` from `task_instance`. `task_id` is needed because an empty
`task_display_name` falls back to it.
- Add `raiseload` on `TaskInstance.dag_run` so the query no longer joins
`dag_run`. Accessing it later raises an error instead of running an extra query.
## Verification
- `uv run --frozen --project airflow-core pytest
airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_event_logs.py`
## Benchmark
A script runs both versions of the query on the same data. Each scenario has
1,500 task instances and 3,075 event logs, and each each value is the median of
40 runs per version, measured after 5 warm-up rounds.
| Scenario | Page size | Endpoint p50 | ORM query p50 |
|---|---|---|---|
| No executor_config | 50 | 14.4 → 12.8 ms (1.1x) | 3.0 → 1.4 ms (2.1x) |
| No executor_config | 100 | 17.3 → 14.4 ms (1.2x) | 5.0 → 2.2 ms (2.3x) |
| KubernetesExecutor `pod_override` | 50 | 23.6 → 14.0 ms (1.7x) | 10.3 →
1.5 ms (7.0x) |
| KubernetesExecutor `pod_override` | 100 | 32.8 → 14.6 ms (2.3x) | 21.8 →
2.7 ms (8.0x) |
<!-- SPDX-License-Identifier: Apache-2.0
https://www.apache.org/licenses/LICENSE-2.0 -->
<!--
Thank you for contributing!
Please provide above a brief description of the changes made in this pull
request.
Write a good git commit message following this guide:
https://chris.beams.io/posts/git-commit/
Please make sure that your code changes are covered with tests.
And in case of new features or big changes remember to adjust the
documentation.
For user-facing UI changes, please attach before/after screenshots (or a
short
screen recording) so reviewers can assess the visual impact.
Feel free to ping (in general) for the review if you do not see reaction for
a few days
(72 Hours is the minimum reaction time you can expect from volunteers) - we
sometimes miss notifications.
In case of an existing issue, reference it using one of the following:
* closes: #ISSUE
* related: #ISSUE
-->
---
##### Was generative AI tooling used to co-author this PR?
<!--
If generative AI tooling has been used in the process of authoring this PR,
please
change below checkbox to `[X]` followed by the name of the tool, uncomment
the "Generated-by".
-->
- [X] Yes - Claude Code
<!--
Generated-by: [Tool Name] following [the
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
-->
---
* Read the **[Pull Request
Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)**
for more information. Note: commit author/co-author name and email in commits
become permanently public when merged.
* For fundamental code changes, an Airflow Improvement Proposal
([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals))
is needed.
* When adding dependency, check compliance with the [ASF 3rd Party License
Policy](https://www.apache.org/legal/resolved.html#category-x).
* For significant user-facing changes create newsfragment:
`{pr_number}.significant.rst`, in
[airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
You can add this file in a follow-up commit after the PR is created so you
know the PR number.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]