From 975f103d25f6e71bdfc16f9106292f0c96bb57bb Mon Sep 17 00:00:00 2001 From: Colin Chartier Date: Tue, 17 Sep 2024 13:12:16 -0400 Subject: [PATCH] Improve performance --- snuba/web/rpc/trace_item_values.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/snuba/web/rpc/trace_item_values.py b/snuba/web/rpc/trace_item_values.py index 2e0c379a76..4ed5337b7e 100644 --- a/snuba/web/rpc/trace_item_values.py +++ b/snuba/web/rpc/trace_item_values.py @@ -50,7 +50,8 @@ def _build_query(request: AttributeValuesRequest) -> Query: from_clause=entity, selected_columns=[ SelectedExpression( - name="attr_value", expression=column("attr_value", alias="attr_value") + name="attr_value", + expression=f.distinct(column("attr_value", alias="attr_value")), ), ], condition=base_conditions_and( @@ -63,11 +64,6 @@ def _build_query(request: AttributeValuesRequest) -> Query: literals_array(None, [literal(request.value_substring_match)]), ), ), - groupby=[ - column("organization_id", alias="organization_id"), - column("attr_key", alias="attr_key"), - column("attr_value", alias="attr_value"), - ], order_by=[ OrderBy( direction=OrderByDirection.ASC, expression=column("organization_id")