Add repository and activity timestamp indexes for issues and pull requests - #501
Open
EngCaioFonseca wants to merge 1 commit into
Open
EngCaioFonseca wants to merge 1 commit into
EngCaioFonseca wants to merge 1 commit into
Conversation
Signed-off-by: Caio Fonseca <engcaiofonseca@protonmail.com>
EngCaioFonseca
force-pushed
the
fix/issue-pr-activity-indexes
branch
from
September 28, 2026 22:18
bede7f1 to
98b4afa
Compare
MoralCode
reviewed
Sep 29, 2026
Comment on lines
+18
to
+21
| with op.get_context().autocommit_block(): | ||
| op.create_index( | ||
| 'issues_idx_repo_id_updated_at', 'issues', ['repo_id', 'updated_at'], | ||
| schema='data', postgresql_concurrently=True, |
Contributor
There was a problem hiding this comment.
was this migration generated with an AI tool, or alembic's built-in --autogenerate flag?
Contributor
|
related to #445 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Workers and metrics frequently filter issues and pull requests by repo_id and creation or update timestamps. The existing indexes cover repo_id or (repo_id, data_collection_date), so basically existing indexes can narrow by repository, but cannot efficiently narrow by the activity timestamps used by workers and metrics
This PR fixes #
The solution/fix to this issue was to add four composite B-tree indexes as follows:
Update the SQLAlchemy models and introduce Alembic migration 45, with concurrent index creation and removal to allow collection writes during migration.
Notes for Reviewers
Signed commits
Generative AI disclosure
Please select one option:
If AI tools were used, please provide details below:
- What tools were used? GPT 6 Astra
- How were these tools used? Initial draft.
- Did you review these outputs before submitting this PR? Yes.