> ## 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.

> Visualize system.query_log data to simplify query debugging and performance optimization

# Query insights

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

The **Query Insights** feature makes ClickHouse's built-in query log easier to use through visualizations and tables. ClickHouse's `system.query_log` table is a key source of information for query optimization, debugging, and monitoring overall cluster health and performance.

<h2 id="query-overview">
  Query overview
</h2>

After selecting a service, the **Monitoring** navigation item in the left sidebar should expand to reveal a new **Query insights** sub-item. Clicking on this option opens the new Query insights page:

<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 Overview" border width="1712" height="790" data-path="images/cloud/sqlconsole/insights_overview.png" />

<h2 id="top-level-metrics">
  Top-level metrics
</h2>

The stat boxes at the top represent some basic top-level query metrics over the selected period of time. Beneath it, we've exposed three time-series charts representing query volume, latency, and error rate broken down by query kind (select, insert, other) over a selected time window. The latency chart can be further adjusted to display p50, p90, and p99 latencies:

<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 Latency Chart" border width="1456" height="384" data-path="images/cloud/sqlconsole/insights_latency.png" />

<h2 id="recent-queries">
  Recent queries
</h2>

Beneath the top-level metrics, a table displays query log entries (grouped by normalized query hash and user) over the selected time window:

<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 Table" border width="1625" height="736" data-path="images/cloud/sqlconsole/insights_recent.png" />

Recent queries can be filtered and sorted by any available field. The table can also be configured to display or hide additional fields such as tables, p90, and p99 latencies.

<h2 id="query-drill-down">
  Query drill-down
</h2>

Selecting a query from the recent queries table will open a flyout containing metrics and information specific to the selected query:

<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 Query Drill down" border width="1889" height="963" data-path="images/cloud/sqlconsole/insights_drilldown.png" />

As we can see from the flyout, this particular query has been run more than 3000 times in the last 24 hours. All metrics in the **Query info** tab are aggregated metrics, but we can also view metrics from individual runs by selecting the **Query history** tab:

<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 Query Information" border width="591" height="961" data-path="images/cloud/sqlconsole/insights_query_info.png" />

<br />

From this pane, the `Settings` and `Profile Events` items for each query run can be expanded to reveal additional information.
