Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group indexes by prefix (common table) #1175

Open
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

nablaone
Copy link
Member

@nablaone nablaone commented Jan 10, 2025

When Grafana queries daily indexes:

  • it adds a time range
  • it adds a list of the indexes within a time range

So if we have a 3-year time range, Grafana will send 1k+ indexes in the query. We transform that list into an OR expression, and hit the query limit.

This PR adds an optimizer that transforms the OR expressions into a single starsWith expression when indexes share the same prefix.

If we have indexes with a pattern daily-YYYYMMDD, we can enable the optimizer:

        '*':
          useCommonTable: true
          target: [ my-clickhouse-data-source ]
          optimizers:
              - group_common_table_indexes:
                  disabled: false
                  properties:
                        "daily-": true

@nablaone nablaone changed the title WIP - Group indexes by prefix (common table) Group indexes by prefix (common table) Jan 13, 2025
@nablaone nablaone marked this pull request as ready for review January 13, 2025 14:52
@nablaone nablaone requested a review from a team as a code owner January 13, 2025 14:52
Comment on lines 737 to 738
if defaultIngestConfig, ok := queryProcessor.Config.IndexConfig[DefaultWildcardIndexName]; ok {
conf.DefaultQueryOptimizers = defaultIngestConfig.Optimizers
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you forget to change name to defaultQueryConfig? If not, I don't know what's going on here 😆

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. Fixed.

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

Successfully merging this pull request may close these issues.

2 participants