Skip to content

How to know what are the most expensive queries? #8881

Discussion options

You must be logged in to vote

for example replace
{hundreds_thousands_cardinality=".*info_1.*info_2"}
with
{label1="info_1",label2="info_2"}

This one in particular would be well welcome. Generally regular expressions with lookbacks (ones with * or +) that are before the end of the query can be very expensive.

Another optimization that we have is prefix matching - db.* is translated to strings.HasPrefix("db") and avoid running a regular expression.

One way to verify the impact of regular expressions is to inspect CPU profiles during these queries.

Perhaps worth noting that it may not always be the complexity of the regular expression, but the number of label values of a label. Matching pod!~"db.*" against 1M strings …

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@agardiman
Comment options

@dimitarvdimitrov
Comment options

Answer selected by agardiman
@agardiman
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants