Skip to content

Commit

Permalink
perf(tf): index by the test run group ID (#2700)
Browse files Browse the repository at this point in the history
perf(tf): index by the test run group ID

Based on the Sentry's backend insights, it appears that in the last 90d we have spent 16.82min running the query that filters out rows based on the «test run group id», therefore index that column to improve the speed of the queries done.
TODO
The alembic migration generated also:
def upgrade():
    op.alter_column('project_events', 'type',
               existing_type=postgresql.ENUM('pull_request', 'branch_push', 'release', 'issue', 'koji_build_tag', 'anitya_version', 'anitya_multiple_versions', name='projecteventtype'),
               type_=sa.Enum('pull_request', 'branch_push', 'release', 'issue', 'koji_build_tag', 'anitya_version', 'anitya_multiple_versions', name='projecteventmodeltype'),
               existing_nullable=True)


def downgrade():
    op.alter_column('project_events', 'type',
               existing_type=sa.Enum('pull_request', 'branch_push', 'release', 'issue', 'koji_build_tag', 'anitya_version', 'anitya_multiple_versions', name='projecteventmodeltype'),
               type_=postgresql.ENUM('pull_request', 'branch_push', 'release', 'issue', 'koji_build_tag', 'anitya_version', 'anitya_multiple_versions', name='projecteventtype'),
               existing_nullable=True)
which is definitely not my change and is basically just a rename of the enumeration

 check what is it about

Reviewed-by: Maja Massarini
Reviewed-by: Laura Barcziová
  • Loading branch information
softwarefactory-project-zuul[bot] authored Jan 20, 2025
2 parents 927dfc5 + c8ed3db commit cf587c9
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
35 changes: 35 additions & 0 deletions alembic/versions/e3cfec8ce0f7_index_tft_test_run_group_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""Index tft_test_run_group_id
Based on the Sentry's backend insights, it appears that in the last 90d
we have spent 16.82min running the query that filters out rows based on
the «test run group id», therefore index that column to improve the speed
of the queries done.
Revision ID: e3cfec8ce0f7
Revises: d625d6c1122f
Create Date: 2025-01-17 16:06:29.833622
"""

from alembic import op

# revision identifiers, used by Alembic.
revision = "e3cfec8ce0f7"
down_revision = "d625d6c1122f"
branch_labels = None
depends_on = None


def upgrade():
op.create_index(
op.f("ix_tft_test_run_targets_tft_test_run_group_id"),
"tft_test_run_targets",
["tft_test_run_group_id"],
unique=False,
)


def downgrade():
op.drop_index(
op.f("ix_tft_test_run_targets_tft_test_run_group_id"), table_name="tft_test_run_targets"
)
2 changes: 1 addition & 1 deletion packit_service/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3325,7 +3325,7 @@ class TFTTestRunTargetModel(GroupAndTargetModelConnector, Base):
# so it will run when the model is initiated, not when the table is made
submitted_time = Column(DateTime, default=datetime.utcnow)
data = Column(JSON)
tft_test_run_group_id = Column(Integer, ForeignKey("tft_test_run_groups.id"))
tft_test_run_group_id = Column(Integer, ForeignKey("tft_test_run_groups.id"), index=True)

copr_builds = relationship(
"CoprBuildTargetModel",
Expand Down

0 comments on commit cf587c9

Please sign in to comment.