Skip to content
This repository was archived by the owner on Nov 7, 2025. It is now read-only.

Conversation

@pdelewski
Copy link
Contributor

@pdelewski pdelewski commented May 16, 2025

This PR extends the current Quesma workflow to allow interrupting query execution when the execution plan contains multiple queries and we’ve already retrieved enough results.

The idea is to split the original query into n queries with different time ranges. If the first one (covering a 15-minute range) returns enough results, we will stop the execution.

The problem is reproducible on kibana_sample_data_flights with the following query:

GET /kibana_sample_data_flights/_search 
{
  "_source": false,
  "fields": [
    {
      "field": "*",
      "include_unmapped": "true"
    },
    {
      "field": "@timestamp",
      "format": "strict_date_optional_time"
    },
    {
      "field": "timestamp",
      "format": "strict_date_optional_time"
    }
  ],
  "highlight": {
    "fields": {
      "*": {}
    },
    "fragment_size": 2147483647,
    "post_tags": [
      "@/kibana-highlighted-field@"
    ],
    "pre_tags": [
      "@kibana-highlighted-field@"
    ]
  },
  "query": {
    "bool": {
      "filter": [
        {
          "range": {
            "timestamp": {
              "format": "strict_date_optional_time",
              "gte": "2025-05-13T08:46:01.926Z",
              "lte": "2025-05-13T09:01:01.926Z"
            }
          }
        }
      ],
      "must": [],
      "must_not": [],
      "should": []
    }
  },
  "runtime_mappings": {
    "hour_of_day": {
      "script": {
        "source": "emit(doc['timestamp'].value.getHour());"
      },
      "type": "long"
    }
  },
  "script_fields": {},
  "size": 500,
  "sort": [
    {
      "timestamp": {
        "format": "strict_date_optional_time",
        "order": "desc",
        "unmapped_type": "boolean"
      }
    },
    {
      "_doc": {
        "order": "desc",
        "unmapped_type": "boolean"
      }
    }
  ],
  "stored_fields": [
    "*"
  ],
  "track_total_hits": false,
  "version": true
}

@pdelewski pdelewski force-pushed the generalizing-execution-plan branch 6 times, most recently from afb5cac to 2cff63a Compare May 22, 2025 10:22
@trzysiek
Copy link
Member

Loving the direction. Can we merge it already?

@pdelewski
Copy link
Contributor Author

Loving the direction. Can we merge it already?

Not ready yet.

@pdelewski
Copy link
Contributor Author

/run-it

1 similar comment
@pdelewski
Copy link
Contributor Author

/run-it

@pdelewski pdelewski force-pushed the generalizing-execution-plan branch 2 times, most recently from 6f22d2d to 981de29 Compare May 22, 2025 13:11
@pdelewski
Copy link
Contributor Author

/run-it

4 similar comments
@pdelewski
Copy link
Contributor Author

/run-it

@pdelewski
Copy link
Contributor Author

/run-it

@pdelewski
Copy link
Contributor Author

/run-it

@pdelewski
Copy link
Contributor Author

/run-it

@pdelewski pdelewski marked this pull request as ready for review May 25, 2025 19:31
@pdelewski pdelewski requested a review from a team as a code owner May 25, 2025 19:31
Copy link
Member

@mieciu mieciu left a comment

Choose a reason for hiding this comment

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

some minor things, other than that - nice one 💪

@pdelewski pdelewski force-pushed the generalizing-execution-plan branch from a1ac8fa to 4329e3f Compare May 29, 2025 11:07
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented May 29, 2025

Deploying quesma with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4329e3f
Status: ✅  Deploy successful!
Preview URL: https://abe2613e.quesma.pages.dev
Branch Preview URL: https://generalizing-execution-plan.quesma.pages.dev

View logs

@pdelewski
Copy link
Contributor Author

/run-it

@pdelewski pdelewski added this pull request to the merge queue May 29, 2025
Merged via the queue into main with commit 6165e9d May 29, 2025
8 checks passed
@pdelewski pdelewski deleted the generalizing-execution-plan branch May 29, 2025 11:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants