-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improved performance of loading list of flows
- Loading branch information
Showing
3 changed files
with
96 additions
and
24 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
server/kraken/migrations/versions/ab9326d5fc02_added_index_to_flows.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
"""added index to flows | ||
Revision ID: ab9326d5fc02 | ||
Revises: 9d8d8713c1ad | ||
Create Date: 2021-05-28 07:44:40.012276 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
from sqlalchemy.dialects import postgresql | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'ab9326d5fc02' | ||
down_revision = '9d8d8713c1ad' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
INDEXES = [ | ||
# create INDEX ix_flows_branch_id_kind on flows(branch_id, kind); | ||
['ix_flows_branch_id_kind', 'flows', ['branch_id', 'kind']], | ||
# create INDEX ix_flows_created on flows(created); | ||
['ix_flows_created', 'flows', ['created']], | ||
# create INDEX ix_runs_flow_id on runs(flow_id); | ||
['ix_runs_flow_id', 'runs', ['flow_id']], | ||
# create INDEX ix_artifacts_run_id on artifacts(run_id); | ||
['ix_artifacts_run_id', 'artifacts', ['run_id']], | ||
# create INDEX ix_artifacts_flow_id on artifacts(flow_id); | ||
['ix_artifacts_flow_id', 'artifacts', ['flow_id']], | ||
] | ||
|
||
|
||
def upgrade(): | ||
for name, table, columns in INDEXES: | ||
try: | ||
print('creating index %s' % name) | ||
op.create_index(name, table, columns) | ||
except Exception: | ||
pass | ||
|
||
|
||
def downgrade(): | ||
for name, table, _ in INDEXES: | ||
try: | ||
print('dropping index %s' % name) | ||
op.drop_index(name, table_name=table) | ||
except Exception: | ||
pass |
This file contains 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
This file contains 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