> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-8c05c8a2.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-8c05c8a2/7_ckVb18cWmplCan/images/cloud/sqlconsole/insights_overview.png?fit=max&auto=format&n=7_ckVb18cWmplCan&q=85&s=688e52c8f83ec0dd1210465e6d0691bb" 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-8c05c8a2/7_ckVb18cWmplCan/images/cloud/sqlconsole/insights_latency.png?fit=max&auto=format&n=7_ckVb18cWmplCan&q=85&s=5454947bcdca4abef8a02a5bdd1a979c" 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-8c05c8a2/7_ckVb18cWmplCan/images/cloud/sqlconsole/insights_recent.png?fit=max&auto=format&n=7_ckVb18cWmplCan&q=85&s=cfc4ba26ab6613feda9196d5ad96fd41" 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-8c05c8a2/7_ckVb18cWmplCan/images/cloud/sqlconsole/insights_drilldown.png?fit=max&auto=format&n=7_ckVb18cWmplCan&q=85&s=fa280480295404f486b9840f78dd254c" 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-8c05c8a2/7_ckVb18cWmplCan/images/cloud/sqlconsole/insights_query_info.png?fit=max&auto=format&n=7_ckVb18cWmplCan&q=85&s=bd5dbbf92ab796f321034018e41928cf" 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.
