Skip to content

Commit

Permalink
feat(spans): Add an index on segment_name (#5671)
Browse files Browse the repository at this point in the history
  • Loading branch information
phacops committed Mar 21, 2024
1 parent f66a9fa commit b34c979
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions snuba/migrations/group_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ def get_migrations(self) -> Sequence[str]:
"0009_spans_add_measure_hashmap",
"0010_spans_add_compression",
"0011_spans_add_index_on_trace_id",
"0012_spans_add_index_on_transaction_name",
]


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from typing import Sequence

from snuba.clusters.storage_sets import StorageSetKey
from snuba.migrations import migration, operations

table_name_prefix = "spans"
column_name = "segment_name"


class Migration(migration.ClickhouseNodeMigration):
blocking = False

def forwards_ops(self) -> Sequence[operations.SqlOperation]:
return [
operations.AddIndex(
storage_set=StorageSetKey.SPANS,
table_name=f"{table_name_prefix}_local",
index_name=f"bf_{column_name}",
index_expression=column_name,
index_type="bloom_filter(0.0)",
granularity=1,
target=operations.OperationTarget.LOCAL,
),
]

def backwards_ops(self) -> Sequence[operations.SqlOperation]:
return [
operations.DropIndex(
StorageSetKey.SPANS,
table_name=f"{table_name_prefix}_local",
index_name=f"bf_{column_name}",
target=operations.OperationTarget.LOCAL,
),
]

0 comments on commit b34c979

Please sign in to comment.