> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-fbfa8bee.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> 将 system.query_log 数据可视化，简化查询调试和性能优化

# Query Insights

export const Image = ({img, alt, size}) => {
  return <Frame>
      <img src={img} alt={alt} />
    </Frame>;
};

**Query Insights** 功能通过可视化视图和表格，让 ClickHouse 内置的查询日志更易于使用。ClickHouse 的 `system.query_log` 表是查询优化、调试以及监控整个集群健康状况和性能的关键信息来源。

<div id="query-overview">
  ## 查询概览
</div>

选择某个服务后，左侧边栏中的 **Monitoring** 导航项会展开，并显示新的 **Query insights** 子项。点击该选项将打开新的 Query insights 页面：

<Image img="https://mintcdn.com/private-7c7dfe99-mintlify-fbfa8bee/YtLHbpLqKXQpx3d8/images/cloud/sqlconsole/insights_overview.png?fit=max&auto=format&n=YtLHbpLqKXQpx3d8&q=85&s=0d652d49bcb888193cd0ac6f2f2e32e1" size="md" alt="Query Insights UI 概览" border width="1712" height="790" data-path="images/cloud/sqlconsole/insights_overview.png" />

<div id="top-level-metrics">
  ## 顶层指标
</div>

顶部的统计框展示了所选时间段内的一些基础顶层查询指标。下方提供了三个时间序列图表，按查询 Kind (select、insert、other) 细分，展示所选时间窗口内的查询量、延迟和错误率。延迟图表还可进一步切换为显示 p50、p90 和 p99 延迟：

<Image img="https://mintcdn.com/private-7c7dfe99-mintlify-fbfa8bee/YtLHbpLqKXQpx3d8/images/cloud/sqlconsole/insights_latency.png?fit=max&auto=format&n=YtLHbpLqKXQpx3d8&q=85&s=364b9601588d3ba628b68c26b964beeb" size="md" alt="Query Insights UI 延迟图表" border width="1456" height="384" data-path="images/cloud/sqlconsole/insights_latency.png" />

<div id="recent-queries">
  ## Recent queries
</div>

在顶层指标下方，表格会显示所选时间窗口内的查询日志条目 (按归一化查询哈希和用户分组) ：

<Image img="https://mintcdn.com/private-7c7dfe99-mintlify-fbfa8bee/YtLHbpLqKXQpx3d8/images/cloud/sqlconsole/insights_recent.png?fit=max&auto=format&n=YtLHbpLqKXQpx3d8&q=85&s=a029b38784d333cb62c2a9fbe1cfb474" size="md" alt="Query Insights UI Recent Queries 表格" border width="1625" height="736" data-path="images/cloud/sqlconsole/insights_recent.png" />

Recent queries 可按任意可用字段进行过滤和排序。该表格还可配置为显示或隐藏其他字段，例如表、p90 和 p99 延迟。

<div id="query-drill-down">
  ## 查询下钻
</div>

在 Recent queries 表中选择某个查询后，会打开一个弹出面板，其中显示该查询特有的指标和信息：

<Image img="https://mintcdn.com/private-7c7dfe99-mintlify-fbfa8bee/YtLHbpLqKXQpx3d8/images/cloud/sqlconsole/insights_drilldown.png?fit=max&auto=format&n=YtLHbpLqKXQpx3d8&q=85&s=3371e463e4ec089807a443432cdada1f" size="md" alt="Query Insights UI 查询下钻" border width="1889" height="963" data-path="images/cloud/sqlconsole/insights_drilldown.png" />

从弹出面板中可以看到，这个查询在过去 24 小时内已运行超过 3000 次。**Query info** 选项卡中的所有指标均为聚合指标；如果选择 **Query history** 选项卡，还可以查看每次单独运行的指标：

<Image img="https://mintcdn.com/private-7c7dfe99-mintlify-fbfa8bee/YtLHbpLqKXQpx3d8/images/cloud/sqlconsole/insights_query_info.png?fit=max&auto=format&n=YtLHbpLqKXQpx3d8&q=85&s=4629def1dbb76a6646c02097e3ee5be4" size="sm" alt="Query Insights UI 查询信息" border width="591" height="961" data-path="images/cloud/sqlconsole/insights_query_info.png" />

<br />

在此面板中，可以展开每次查询运行对应的 `Settings` 和 `Profile Events` 项，以查看更多信息。
