Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up existing indices on Upload (aka ReportSession) #442

Open
wants to merge 1 commit into
base: swatinem/upload-idx-part1
Choose a base branch
from

Conversation

Swatinem
Copy link
Contributor

This in particular cleans up the existing indices that exist in the production DB but not in django:

  • reports_upload_order_number_upload_type_report_id_index: This index actually has the reverse order that the one above, which means that frequent updates to the order_number lead to a lot of costly index updates.
  • reports_upload_report_id_f6b4ffae: Queries on report_id should already been covered by the newly added index on report_id+upload_type.
  • reports_upload_created_at_index: We never query by created_at directly. The only place where we use this is in an ORDER BY that is already covered by the report_id.

This in particular cleans up the existing indices that exist in the production DB but not in django:

- `reports_upload_order_number_upload_type_report_id_index`:
  This index actually has the *reverse* order that the one above, which means that frequent updates
  to the `order_number` lead to a lot of costly index updates.
- `reports_upload_report_id_f6b4ffae`: Queries on `report_id` should already been covered by the
   newly added index on `report_id`+`upload_type`.
- `reports_upload_created_at_index`: We never query by `created_at` directly. The only place where we
  use this is in an `ORDER BY` that is already covered by the `report_id`.
@Swatinem Swatinem self-assigned this Nov 28, 2024
@Swatinem
Copy link
Contributor Author

Looks like the created_at index might be used only for this query here:
https://github.com/codecov/worker/blob/ad3621cbee3619ec1b47ee55a1050e8be4343dda/tasks/brolly_stats_rollup.py#L53

But for that case, I believe having an index would make sense, as otherwise it would do a full table scan there :-D

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.

2 participants