Skip to content

more indexes on system_requests #114

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

Merged
merged 4 commits into from
Jun 13, 2024
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
31 changes: 31 additions & 0 deletions alembic/versions/d5d4afc97d40_more_indexes_on_system_requests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""more indexes on system requests.

Revision ID: d5d4afc97d40
Revises: ca178571bdc5
Create Date: 2024-06-13 12:36:47.252394

"""

import alembic

# revision identifiers, used by Alembic.
revision = "d5d4afc97d40"
down_revision = "ca178571bdc5"
branch_labels = None
depends_on = None


def upgrade() -> None:
alembic.op.create_index("idx_system_requests_status", "system_requests", ["status"])
alembic.op.create_index(
"idx_system_requests_created_at", "system_requests", ["created_at"]
)
alembic.op.create_index(
"idx_system_requests_finished_at", "system_requests", ["finished_at"]
)


def downgrade() -> None:
alembic.op.drop_index("idx_system_requests_status")
alembic.op.drop_index("idx_system_requests_created_at")
alembic.op.drop_index("idx_system_requests_finished_at")
6 changes: 3 additions & 3 deletions cads_broker/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,17 @@ class SystemRequest(BaseModel):
request_uid = sa.Column(sa.dialects.postgresql.UUID(False), primary_key=True)
process_id = sa.Column(sa.Text, index=True)
user_uid = sa.Column(sa.Text, index=True)
status = sa.Column(status_enum)
status = sa.Column(status_enum, index=True)
cache_id = sa.Column(sa.Integer, index=True)
request_body = sa.Column(JSONB, nullable=False)
request_metadata = sa.Column(JSONB)
response_error = sa.Column(JSONB, default={})
response_log = sa.Column(JSONB, default="[]")
response_user_visible_log = sa.Column(JSONB, default="[]")
response_metadata = sa.Column(JSONB)
created_at = sa.Column(sa.TIMESTAMP, default=sa.func.now())
created_at = sa.Column(sa.TIMESTAMP, default=sa.func.now(), index=True)
started_at = sa.Column(sa.TIMESTAMP)
finished_at = sa.Column(sa.TIMESTAMP)
finished_at = sa.Column(sa.TIMESTAMP, index=True)
updated_at = sa.Column(sa.TIMESTAMP, default=sa.func.now(), onupdate=sa.func.now())
origin = sa.Column(sa.Text, default="ui")
portal = sa.Column(sa.Text)
Expand Down
Loading