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

perf: save and exploit distrinction between resources and attributes #287

Open
ernado opened this issue Jan 8, 2024 · 0 comments
Open
Labels
perf Performance improvements and benchmarks

Comments

@ernado
Copy link
Member

ernado commented Jan 8, 2024

Following #286:

During query execution, we should first analyze all label matches and group them into "attribute-only", "resource-only" or "both".

To do it fast, there should be a materialized view or additional table that holds this information.

So, before:

SELECT name, timestamp, mapping, value, flags, attributes, resource
FROM `metrics_points`
WHERE true
  AND toUnixTimestamp64Nano(timestamp) >= 1704546540000000000
  AND toUnixTimestamp64Nano(timestamp) <= 1704549765000000000
  AND (
    JSONExtractString(attributes, 'instance') = 'host-0'
        OR JSONExtractString(resource, 'instance') = 'host-0'
    )
  AND (
    JSONExtractString(attributes, 'job') = 'node_exporter'
        OR JSONExtractString(resource, 'job') = 'node_exporter'
    )
  AND (
    JSONExtractString(attributes, 'mode') = 'user'
        OR JSONExtractString(resource, 'mode') = 'user'
    )
  AND (
    name = 'node_cpu_seconds_total'
    )
ORDER BY timestamp;

After:

SELECT name, timestamp, mapping, value, flags, attributes, resource
FROM `metrics_points`
WHERE true
  AND toUnixTimestamp64Nano(timestamp) >= 1704546540000000000
  AND toUnixTimestamp64Nano(timestamp) <= 1704549765000000000
  AND JSONExtractString(resource, 'instance') = 'host-0'
  AND JSONExtractString(resource, 'job') = 'node_exporter'
  AND JSONExtractString(attributes, 'mode') = 'user'
  AND name = 'node_cpu_seconds_total'
ORDER BY timestamp;
@ernado ernado added the perf Performance improvements and benchmarks label Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf Performance improvements and benchmarks
Projects
None yet
Development

No branches or pull requests

1 participant