Skip to content

Commit

Permalink
fix: add limits to suggestion query
Browse files Browse the repository at this point in the history
  • Loading branch information
nityanandagohain committed Sep 16, 2024
1 parent 1b59719 commit b9e729e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/query-service/app/clickhouseReader/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -4364,6 +4364,9 @@ func (r *ClickHouseReader) getValuesForLogAttributes(
) ([][]any, *model.ApiError) {
// query top `limit` distinct values seen for `tagKey`s of interest
// ordered by timestamp when the value was seen

// we added the settings max_rows_to_group_by=100, group_by_overflow_mode = 'break'
// to avoid query from taking up all the resources when value is high cardinality.
query := fmt.Sprintf(
`
select tagKey, stringTagValue, int64TagValue, float64TagValue
Expand All @@ -4383,7 +4386,7 @@ func (r *ClickHouseReader) getValuesForLogAttributes(
max(timestamp) as ts
from %s.%s
where tagKey in $1
group by (tagKey, stringTagValue, int64TagValue, float64TagValue)
group by (tagKey, stringTagValue, int64TagValue, float64TagValue) SETTINGS max_rows_to_group_by = 100, group_by_overflow_mode = 'break', max_threads=4
)
)
where rank <= %d
Expand Down

0 comments on commit b9e729e

Please sign in to comment.