Skip to content

[FEATURE] Remove unnecessary filter for DataHistogram aggregation #4873

Closed

Description

@LantaoJin

Is your feature request related to a problem?
big5 query

source = big5
| where `@timestamp` >= '2023-01-01 00:00:00' and `@timestamp` < '2023-01-03 00:00:00'
| stats count() by span(`@timestamp`, 1m)

The current plan is

{
  "from": 0,
  "size": 0,
  "timeout": "1m",
  "query": {
    "bool": {
      "must": [
        {
          "range": {
            "@timestamp": {
              "from": "2023-01-01T00:00:00.000Z",
              "to": "2023-01-03T00:00:00.000Z",
              "include_lower": true,
              "include_upper": false,
              "format": "date_time",
              "boost": 1
            }
          }
        },
        {
          "exists": {
            "field": "@timestamp",
            "boost": 1
          }
        }
      ],
      "adjust_pure_negative": true,
      "boost": 1
    }
  },
  "_source": {
    "includes": [
      "@timestamp"
    ],
    "excludes": []
  },
  "aggregations": {
    "composite_buckets": {
      "composite": {
        "size": 10000,
        "sources": [
          {
            "span(`@timestamp`,1m)": {
              "date_histogram": {
                "field": "@timestamp",
                "missing_bucket": false,
                "order": "asc",
                "fixed_interval": "1m"
              }
            }
          }
        ]
      }
    }
  }
}

The expected plan is

{
  "from": 0,
  "size": 0,
  "timeout": "1m",
  "query": {
    "bool": {
      "range": {
      "@timestamp": {
        "from": "2023-01-01T00:00:00.000Z",
        "to": "2023-01-03T00:00:00.000Z",
        "include_lower": true,
        "include_upper": false,
        "format": "date_time",
        "boost": 1
      }
    }
  },
  "_source": {
    "includes": [
      "@timestamp"
    ],
    "excludes": []
  },
  "aggregations": {
    "composite_buckets": {
      "composite": {
        "size": 10000,
        "sources": [
          {
            "span(`@timestamp`,1m)": {
              "date_histogram": {
                "field": "@timestamp",
                "missing_bucket": false,
                "order": "asc",
                "fixed_interval": "1m"
              }
            }
          }
        ]
      }
    }
  }
}

The execution time reduced from 500ms to 20ms, which has 25x time improved.

Activity

  1. added
    enhancement
    pushdown
    on Nov 27, 2025
  2. self-assigned this
    on Nov 27, 2025
  3. changed the title [-][FEATURE] Replace DataHistogram composite aggregation with DataHistogram aggregation[/-] [+][FEATURE] Remove unnecessary filter for DataHistogram aggregation[/+] on Nov 27, 2025
  4. moved this from Not Started to In progress in PPL Trackeron Nov 27, 2025
  5. moved this from In progress to Done in PPL Trackeron Nov 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementperformancepushdown

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions