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

🐛 Improve db performance when searching files #5744

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"""add indices to file_meta_data and projects tables

Revision ID: b13ca15c7ef8
Revises: 0ed9f6eabeba
Create Date: 2024-04-26 08:11:52.163445+00:00

"""
from alembic import op

# revision identifiers, used by Alembic.
revision = "b13ca15c7ef8"
down_revision = "0ed9f6eabeba"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_index(
op.f("ix_file_meta_data_is_directory"),
"file_meta_data",
["is_directory"],
unique=False,
)
op.create_index(
op.f("ix_file_meta_data_project_id"),
"file_meta_data",
["project_id"],
unique=False,
)
op.create_index(
op.f("ix_file_meta_data_user_id"), "file_meta_data", ["user_id"], unique=False
)
op.create_index(
op.f("ix_projects_prj_owner"), "projects", ["prj_owner"], unique=False
)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f("ix_projects_prj_owner"), table_name="projects")
op.drop_index(op.f("ix_file_meta_data_user_id"), table_name="file_meta_data")
op.drop_index(op.f("ix_file_meta_data_project_id"), table_name="file_meta_data")
op.drop_index(op.f("ix_file_meta_data_is_directory"), table_name="file_meta_data")
# ### end Alembic commands ###
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
sa.Column("location", sa.String()),
sa.Column("bucket_name", sa.String()),
sa.Column("object_name", sa.String()),
sa.Column("project_id", sa.String()),
sa.Column("project_id", sa.String(), index=True),
sa.Column("node_id", sa.String()),
sa.Column("user_id", sa.String()),
sa.Column("user_id", sa.String(), index=True),
sa.Column("file_id", sa.String(), primary_key=True),
sa.Column("created_at", sa.String()),
sa.Column("last_modified", sa.String()),
Expand Down Expand Up @@ -46,6 +46,7 @@
nullable=False,
server_default=sa.text("false"),
doc="Set True when file_id is a directory",
index=True,
),
sa.Column(
"sha256_checksum",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class ProjectType(enum.Enum):
),
nullable=True,
doc="Project's owner",
index=True,
),
sa.Column(
"creation_date",
Expand Down
Loading