Skip to content

fix deadline callback migration to improve query performance#63640

Closed
wjddn279 wants to merge 2 commits intoapache:mainfrom
wjddn279:improve-deadline-callback-upgrade-performance
Closed

fix deadline callback migration to improve query performance#63640
wjddn279 wants to merge 2 commits intoapache:mainfrom
wjddn279:improve-deadline-callback-upgrade-performance

Conversation

@wjddn279
Copy link
Copy Markdown
Contributor

releated: #63532

Through my testing, I confirmed that the bottleneck of this migration is not serialization, but the update query being executed one row at a time.

Even after excluding all performance bottlenecks such as serialization (including Python dict deserialization), the query performance was still poor. By changing the update to a bulk update, I confirmed an improvement from 2,000 rows/sec to 40,000 rows/sec (PostgreSQL), and 20,000 rows/sec on MySQL.

Even though the existing serialization code had no significant impact on performance, so it was replaced with code that simply gets values from the existing column's dict. (slight performance improvement)


Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

  • Read the 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) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

UPDATE deadline2
SET callback_id = v.callback_id, missed = v.missed
FROM (VALUES {values_clause}) AS v(deadline_id, callback_id, missed)
WHERE deadline2.id = v.deadline_id
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fails on real data upgrade.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, there was a discussion about this, and it seems to fail depending on the environment. Since there's another PR with an alternative fix, I'll close this one.

@wjddn279 wjddn279 closed this Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:db-migrations PRs with DB migration area:deadline-alerts AIP-86 (former AIP-57)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants