Skip to content

Commit

Permalink
perf(chstorage): use GROUP BY hack to deduplicate span names
Browse files Browse the repository at this point in the history
  • Loading branch information
tdakkota committed Dec 5, 2024
1 parent 8505a42 commit a630a6a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/chstorage/querier_traces.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,10 @@ func (q *Querier) spanNames(ctx context.Context, tag traceql.Attribute, opts tra
var (
name = new(proto.ColStr).LowCardinality()
query = chsql.Select(table, chsql.Column("name", name)).
Distinct(true).
// Select deduplicated column by using GROUP BY, since DISTINCT is not optimized by Clickhouse.
//
// See https://github.com/ClickHouse/ClickHouse/issues/4670
Distinct(true).GroupBy(chsql.Ident("name")).
Where(traceInTimeRange(opts.Start, opts.End))
)
{
Expand Down

0 comments on commit a630a6a

Please sign in to comment.