Skip to content

orderby adjustment#768

Merged
jason-ford-codecov merged 2 commits intomainfrom
feature/materialized_cleanup-ordering-seq-scan
Mar 12, 2026
Merged

orderby adjustment#768
jason-ford-codecov merged 2 commits intomainfrom
feature/materialized_cleanup-ordering-seq-scan

Conversation

@jason-ford-codecov
Copy link
Copy Markdown
Contributor

@jason-ford-codecov jason-ford-codecov commented Mar 12, 2026

this should help with the sequential scan on the uploadbread crumb table

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.


Note

Low Risk
Small, targeted query-planning tweak limited to eager-eval ID materialization for UploadBreadcrumb; should not change result sets but could affect performance characteristics.

Overview
Adjusts cleanup query simplification to explicitly clear ORDER BY when eagerly materializing IDs for UploadBreadcrumb querysets (via queryset.order_by()), aiming to improve the planner behavior and avoid expensive scans during cleanup relation expansion.

Written by Cursor Bugbot for commit fe29224. This will update automatically on new commits. Configure here.

Copy link
Copy Markdown
Contributor

@thomasrockhu-codecov thomasrockhu-codecov left a comment

Choose a reason for hiding this comment

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

Just make an if condition so that this tackles UploadBreadcrumbs

@sentry
Copy link
Copy Markdown
Contributor

sentry bot commented Mar 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.26%. Comparing base (8eb0409) to head (fe29224).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #768   +/-   ##
=======================================
  Coverage   92.26%   92.26%           
=======================================
  Files        1304     1304           
  Lines       47922    47924    +2     
  Branches     1628     1628           
=======================================
+ Hits        44217    44219    +2     
  Misses       3396     3396           
  Partials      309      309           
Flag Coverage Δ
workerintegration 58.55% <0.00%> (-0.01%) ⬇️
workerunit 90.39% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@codecov-notifications
Copy link
Copy Markdown

codecov-notifications bot commented Mar 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.


threshold = _get_eager_eval_threshold()
if queryset.model == UploadBreadcrumb:
queryset = queryset.order_by()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Model-specific order_by fix could apply to all models

Low Severity

The order_by() optimization is hardcoded only for UploadBreadcrumb, but ordering is never needed when materializing IDs for IN filters. Other models also have Meta.ordering (e.g., Repository has ordering = ["-repoid"]) and would benefit from the same treatment. The conditional if queryset.model == UploadBreadcrumb could simply be removed so queryset = queryset.order_by() applies unconditionally, avoiding the same sequential-scan risk for any model with default ordering — and eliminating a model-specific special case from a generic function.

Fix in Cursor Fix in Web

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.

Might be worth following this suggestion if it's an improvement, though I'd prompt AI first to see if all other models would benefit from this, cause some could be hindered

@jason-ford-codecov jason-ford-codecov added this pull request to the merge queue Mar 12, 2026
@jason-ford-codecov jason-ford-codecov removed this pull request from the merge queue due to a manual request Mar 12, 2026
@jason-ford-codecov jason-ford-codecov added this pull request to the merge queue Mar 12, 2026
Merged via the queue into main with commit 50180a7 Mar 12, 2026
40 checks passed
@jason-ford-codecov jason-ford-codecov deleted the feature/materialized_cleanup-ordering-seq-scan branch March 12, 2026 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants