Skip to content

Commit aaa8d5e

Browse files
committed
Simplify Published Variant MV Indexes
Simplifies the indexes on the published variants materialized view to speed up refresh jobs. Previously, the five indexes on this mv created large amounts of write overhead. Due to the nature of concurrent mv refreshes, this caused jobs to run for huge amounts of time with no sign of finishing. The single simpler unique index on only id fields of the table should result in much lower index maintenance overhead and much quicker mv refreshs.
1 parent 60d4e0d commit aaa8d5e

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
"""simplify published variants mv indexes
2+
3+
Revision ID: 4726e4dddde8
4+
Revises: b85bc7b1bec7
5+
Create Date: 2025-03-25 10:46:46.641777
6+
7+
"""
8+
9+
from alembic import op
10+
11+
from mavedb.models.published_variant import signature
12+
13+
14+
# revision identifiers, used by Alembic.
15+
revision = "4726e4dddde8"
16+
down_revision = "b85bc7b1bec7"
17+
branch_labels = None
18+
depends_on = None
19+
20+
21+
def upgrade():
22+
# ### commands auto generated by Alembic - please adjust! ###
23+
op.drop_index(f"idx_{signature}_variant_id", signature)
24+
op.drop_index(f"idx_{signature}_variant_urn", signature)
25+
op.drop_index(f"idx_{signature}_mapped_variant_id", signature)
26+
op.drop_index(f"idx_{signature}_score_set_id", signature)
27+
op.drop_index(f"idx_{signature}_score_set_urn", signature)
28+
29+
op.create_index(
30+
f"idx_{signature}_ids",
31+
signature,
32+
["mapped_variant_id", "variant_id", "score_set_id"],
33+
unique=True,
34+
)
35+
# ### end Alembic commands ###
36+
37+
38+
def downgrade():
39+
# ### commands auto generated by Alembic - please adjust! ###
40+
op.drop_index(f"idx_{signature}_ids", signature)
41+
42+
op.create_index(
43+
f"idx_{signature}_variant_id",
44+
signature,
45+
["variant_id"],
46+
unique=False,
47+
)
48+
op.create_index(
49+
f"idx_{signature}_variant_urn",
50+
signature,
51+
["variant_urn"],
52+
unique=False,
53+
)
54+
op.create_index(
55+
f"idx_{signature}_score_set_id",
56+
signature,
57+
["score_set_id"],
58+
unique=False,
59+
)
60+
op.create_index(
61+
f"idx_{signature}_score_set_urn",
62+
signature,
63+
["score_set_urn"],
64+
unique=False,
65+
)
66+
op.create_index(
67+
f"idx_{signature}_mapped_variant_id",
68+
signature,
69+
["mapped_variant_id"],
70+
unique=True,
71+
)
72+
# ### end Alembic commands ###

0 commit comments

Comments
 (0)