Skip to content

Commit

Permalink
Fix very slow user data table query
Browse files Browse the repository at this point in the history
by adding an index on extension.
Fixes extremely slow tool form building.
  • Loading branch information
mvdbeek committed Mar 25, 2024
1 parent dc7f893 commit 12aacf5
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/galaxy/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10910,7 +10910,7 @@ def __repr__(self):
Column("blurb", TrimmedString(255)),
Column("peek", TEXT, key="_peek"),
Column("tool_version", TEXT),
Column("extension", TrimmedString(64)),
Column("extension", TrimmedString(64), index=True),
Column("metadata", MetadataType, key="_metadata"),
Column("metadata_deferred", Boolean, key="metadata_deferred"),
Column("parent_id", Integer, ForeignKey("history_dataset_association.id"), nullable=True),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""Add index on history_dataset_association extension

Check failure on line 1 in lib/galaxy/model/migrations/alembic/versions_gxy/55f02fd8ab6c_add_index_on_hda_extension.py

View workflow job for this annotation

GitHub Actions / Test (3.8)

Imports are incorrectly sorted and/or formatted.

Check failure on line 1 in lib/galaxy/model/migrations/alembic/versions_gxy/55f02fd8ab6c_add_index_on_hda_extension.py

View workflow job for this annotation

GitHub Actions / Test (3.12)

Imports are incorrectly sorted and/or formatted.
Revision ID: 55f02fd8ab6c
Revises: 2dc3386d091f
Create Date: 2024-03-25 11:14:40.005394
"""

from galaxy.model.database_object_names import build_index_name
from galaxy.model.migrations.util import (
create_index,
drop_index,
)


# revision identifiers, used by Alembic.
revision = "55f02fd8ab6c"
down_revision = "2dc3386d091f"
branch_labels = None
depends_on = None


hda_table_name = "history_dataset_association"
hda_extension_column_name = "extension"
hda_extension_index_name = build_index_name(hda_table_name, hda_extension_column_name)


def upgrade():
create_index(hda_extension_index_name, hda_table_name, [hda_extension_column_name])


def downgrade():
drop_index(hda_extension_index_name, hda_table_name)

0 comments on commit 12aacf5

Please sign in to comment.