plan-cache-qds-bridge

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Locate one query across cache and Query Store

在缓存和 Query Store 中定位单个查询

Use the lookup queries for identity resolution, database-scoped lookup, and the cache/history comparison. This is a read-only investigation; do not flush the cache, enable Query Store, force a plan or execute the workload just to make evidence appear.
使用查询定位语句进行身份识别、数据库范围定位以及缓存/历史记录对比。这是一项只读调查;请勿清空缓存、启用 Query Store、强制生成计划,或仅为获取证据而执行工作负载。

Scope

范围

  • For cache-wide plan cache health, use
    plan-cache-analysis
    .
  • For workload-wide historical regression, use
    query-store-investigation
    .
  • 若要检查整个缓存的 plan cache 健康状况,请使用
    plan-cache-analysis
    。
  • 若要调查整个工作负载的历史回归问题,请使用
    query-store-investigation
    。

Available capabilities

可用能力

Use the connected host's SQL query tool: prefer
mssql_execute_query
from the SQL Tools MCP server that ships with the
microsoft-sql-admin
plugin, or an already authorized SQL CLI connection. If that server is not connected or lists no connections, follow the
sql-tools-mcp-setup
skill, which asks before installing or configuring anything. Verify the selected server/database and permissions before interpreting absence as a finding.
If the catalog exposes
getEstimatedShowplanForQuery
, it can resolve a complete statement's optimizer hash without executing the workload. Compilation can still require permissions, locks and auto-statistics work; skip it when the requested scope prohibits those effects. Otherwise use the reference's text-search path and report ambiguity. Do not send
GO
or rely on SET state across independent raw-query calls. No tool available means provide the diagnostic SQL and identify what remains unobserved.
使用已连接主机的 SQL 查询工具:优先使用随
microsoft-sql-admin
插件提供的 SQL Tools MCP 服务器中的
mssql_execute_query
,或使用已获得授权的 SQL CLI 连接。如果该服务器未连接或未列出任何连接,请按照
sql-tools-mcp-setup
skill 操作,该 skill 会在安装或配置任何内容之前征求同意。在将缺失情况解读为调查结论之前,请先验证所选服务器/数据库和权限。
如果系统目录公开了
getEstimatedShowplanForQuery
,则可以在不执行工作负载的情况下解析完整语句的 optimizer hash。编译过程仍可能需要权限、锁和自动统计信息维护;当请求的范围禁止这些影响时,应跳过编译。否则,请使用参考资料中的文本搜索路径并报告歧义。不要发送
GO
,也不要依赖 SET 状态在相互独立的原始查询调用之间持续生效。如果没有可用工具,请提供诊断 SQL,并明确指出哪些内容仍无法观测。

Evidence rules

证据规则

  • Establish Query Store state, capture coverage and the requested time window. Missing history can mean disabled capture, retention or permissions, not that a query never ran.
  • A plan handle identifies a batch and is volatile. Resolve the intended statement and offsets before associating it with a query hash. A query hash is a matching aid, not proof of semantic identity or database ownership.
  • Keep target database, query text/context and statement identity in the join. An ad hoc cache row with null database ID is ambiguous; require independent database evidence rather than assuming it belongs to this connection.
  • Aggregate Query Store intervals using execution-weighted metrics in a common time window. Keep regular, aborted and exception executions distinguishable. Cache cumulative counters and historical interval averages are different populations; report their units and reset/retention limits.
  • A changed plan hash is evidence of a different plan, not proof of a regression. Compare compatible workload/context and runtime evidence before recommending action. Reuse a matching supplied plan or existing compact tool results.
Return query identity and uncertainty, cache observations, historical coverage, plan differences, and the next smallest useful investigation. When delegated, preserve the caller's requested scope and output format.
  • 确定 Query Store 状态、捕获覆盖范围和请求的时间窗口。历史记录缺失可能意味着捕获被禁用、保留期已过或权限不足,而不能说明该查询从未运行。
  • plan handle 标识一个 batch,且具有易失性。将预期语句及其偏移量解析清楚后,再与 query hash 关联。query hash 只能作为匹配辅助信息,不能证明语义身份或数据库归属关系。
  • 关联时,应保留目标数据库、查询文本/上下文和语句身份。数据库 ID 为 null 的临时缓存行含义不明确;应要求独立的数据库证据,而不是假定它属于当前连接。
  • 在统一的时间窗口内,使用执行次数加权的指标汇总 Query Store 区间。区分正常执行、中止执行和异常执行。缓存累计计数器与历史区间平均值属于不同的数据总体;应报告它们的单位以及重置/保留限制。
  • plan hash 发生变化只能证明使用了不同计划,不能直接证明出现了性能回归。在建议采取行动之前,请比较兼容的工作负载/上下文和运行时证据。优先复用匹配的现有计划或已有的精简工具结果。
返回查询身份及其不确定性、缓存观察结果、历史覆盖范围、计划差异,以及下一步最小且最有价值的调查。当任务被委派时,应保留调用方要求的范围和输出格式。