schema_version: 1
id: representative-business-slow-queries-in-saas01-during-latest-window
title: Representative business slow queries in saas01 during the latest completed Beijing 11:00-11:05 window
status: active
owner: codex
evaluation:
  mode: adhoc_evidence
environment:
  profile: stable-dedicated
  cluster_label: saas01
  cluster_id: '10989049060142230334'
  cluster_type: dedicated
  tidb_version: v8.5.x
time_window:
  resolved_by_output: resolved_window
runtime:
  hooks:
  - id: resolve_runtime_window
    stage: before_acp
    kind: python_script
    path: runtime_hook.py
    output_id: resolved_window
    args:
      - resolve-window
      - --cluster-id
      - '{{environment.cluster_id}}'
      - --cluster-label
      - '{{environment.cluster_label}}'
      - --local-hour
      - '11'
      - --local-minute
      - '0'
      - --duration-minutes
      - '5'
      - --top-n
      - '3'
  - id: build_runtime_reference
    stage: before_judge
    kind: python_script
    path: runtime_hook.py
    output_id: reference_answer
    args:
      - build-reference
      - --cluster-id
      - '{{environment.cluster_id}}'
      - --cluster-label
      - '{{environment.cluster_label}}'
      - --start
      - '{{runtime.resolved_window.start}}'
      - --end
      - '{{runtime.resolved_window.end}}'
      - --top-n
      - '3'
prompt:
  text: |
    帮我看下 {{environment.cluster_label}} 这个集群（{{environment.cluster_id}}）在 {{runtime.resolved_window.start}} 到 {{runtime.resolved_window.end}} 这 5 分钟里，最值得先看的 3 条业务慢查询是谁。

    事务控制语句像 `COMMIT`、`START TRANSACTION`、`BEGIN`、`ROLLBACK` 这种别算进去。

    我只看最后结果。最终只输出一个 `json` 代码块，字段必须严格为：
    `cluster_id`、`window`、`evidence_sufficient`、`slow_queries`

    `slow_queries` 必须按下面的规则排序：
    1. 先按 `exec_count` 从高到低；
    2. 如果 `exec_count` 一样，再按 `avg_time_s` 从高到低；
    3. 如果还一样，再按 `digest` 字典序。

    `slow_queries` 长度必须是 3。每个元素都只能包含：
    `digest`、`exec_count`、`avg_time_s`

    不要输出额外字段，不要输出额外解释，也不要把说明写进 JSON。

    JSON 结构如下：

    ```json
    {
      "cluster_id": "10989049060142230334",
      "window": {
        "start": "2026-01-01T03:00:00Z",
        "end": "2026-01-01T03:05:00Z"
      },
      "evidence_sufficient": true,
      "slow_queries": [
        {
          "digest": "18576e217f5f93fa2a934f84290447caa4b783cab493503c4ad71c912ea16930",
          "exec_count": 2492,
          "avg_time_s": 2.282
        },
        {
          "digest": "2d142ccf344650a9226ea89d072cdae8eeb850fff82d96e8bf0406cdf52ee69f",
          "exec_count": 1960,
          "avg_time_s": 1.332
        },
        {
          "digest": "1bcaebe8c0950a9559d1a5ecc0f1c075733310e820348299993dd34d68e5b36a",
          "exec_count": 455,
          "avg_time_s": 2.372
        }
      ]
    }
    ```

    如果证据不足，请把 `evidence_sufficient` 设为 `false`，并把 `slow_queries` 设为空数组。
tags:
- slow-query
- structured-output
- adhoc-evidence
- saas01
case_tier: P1
cost_tier: low
followup:
  scheduled_max_followups: 0
execution:
  acp_bash_timeout_s: 300
