Skip to content

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

@ernado

Description

@ernado

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;

Metadata

Metadata

Assignees

No one assigned

    Labels

    perfPerformance improvements and benchmarks

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions