Microsoft Fabric Updates Blog

Unlock the Power of Query insights and become a Fabric Data Warehouse performance detective

In today’s data-driven landscape, optimizing query performance is paramount for organizations relying on data warehouses. Microsoft Fabric’s Query Insights emerges as a powerful tool, enabling data professionals to delve deep into query behaviors and enhance system efficiency.

Understanding Query Insights

Query Insights in Microsoft Fabric serves as a centralized repository, storing 30 days of historical query data. It offers actionable insights, allowing users to analyze and refine query performance effectively. By consolidating execution data from SQL queries, it provides a comprehensive view of system operations.

Key features:

  • Historical query data: Track performance changes over time, facilitating trend analysis and proactive optimization.
  • Aggregated insights: Identify long-running queries, frequent users, and potential bottlenecks through data aggregation based on query shapes.
  • Resource utilization metrics: Analyze CPU usage and data scanned to evaluate query efficiency.

Practical application of Query Insights

To harness the full potential of Query Insights, it’s essential to understand its system views:

1. Analyzing Query Execution with exec_requests_history

This view provides details on each completed SQL request, including execution times and resource consumption.

Example query:

SELECT

distributed_statement_id,

login_name,

start_time,

end_time,

total_elapsed_time_ms,

allocated_cpu_time_ms

FROM

queryinsights.exec_requests_history

ORDER BY

total_elapsed_time_ms DESC;

This query retrieves a list of executed requests, highlighting those with the longest execution times.

2. Analyzing user sessions with exec_sessions_history

This view offers insights into completed sessions, aiding in understanding user activity and session durations.

Example query:

SELECT

session_id,

login_name,

session_start_time,

session_end_time,

total_query_elapsed_time_ms

FROM

queryinsights.exec_sessions_history

ORDER BY

total_query_elapsed_time_ms DESC;

This query lists sessions by duration, helping identify prolonged user activities.

3. Identifying Long-Running Queries

For pinpointing performance issues, long_running_queries helps track queries exceeding typical execution times.

Example query:

SELECT * FROM queryinsights.long_running_queries

WHERE last_run_command LIKE ‘%<some_label>%’

ORDER BY median_total_elapsed_time_ms DESC;

This query aggregates long-running queries, allowing for targeted optimization efforts.

4. Tracking Frequently Run Queries

The frequently_run_queries view helps highlight queries executed frequently, presenting opportunities for performance tuning.

Example query:

SELECT * FROM queryinsights.frequently_run_queries

WHERE last_run_command LIKE ‘%<some_label>%’

ORDER BY number_of_successful_runs DESC;

This query showcases the most frequently executed queries, guiding optimization priorities.

The importance of Query Hash for identifying similar queries

One of the most effective ways to analyze query performance is by leveraging the query_hash. This unique identifier groups similar queries, making it easier to detect patterns, optimize recurring queries, and reduce redundant execution.

Using query_hash, users can:

  • Identify performance trends across similar queries.
  • Detect and optimize queries that frequently run with slight variations.
  • Compare execution times of the same logical query structure over time.

Analyzing CPU usage & cache utilization

Efficient monitoring of CPU usage and cache utilization can significantly enhance performance analysis.

1. Tracking CPU usage

To identify queries consuming excessive CPU time, leverage the

SELECT TOP 100 distributed_statement_id, query_hash, allocated_cpu_time_ms, label, command

FROM queryinsights.exec_requests_history

ORDER BY allocated_cpu_time_ms DESC;

This query helps determine which queries are CPU-intensive and may require optimization.

2. Identifying cache utilization with data scanned

Cache efficiency can be inferred by analyzing the amount of data scanned. Queries with no data_scanned_remote_storage_mb indicate effective caching.

SELECT distributed_statement_id, query_hash, data_scanned_remote_storage_mb, data_scanned_memory_mb, data_scanned_disk_mb, label, command

FROM queryinsights.exec_requests_history

ORDER BY data_scanned_remote_storage_mb DESC;

Queries with minimal data scanned likely benefited from caching, whereas those scanning large datasets may indicate poor cache utilization.

Using labels smartly with Query Insights

Labels can be a game-changer for organizing and analyzing queries efficiently in Query Insights. By tagging queries with meaningful labels, teams can group and track performance more effectively.

1. Assigning labels to Queries

SELECT * FROM FactResellerSales

OPTION (LABEL = ‘q17’);

This query helps analyze labeled queries to identify performance trends based on assigned categories.

2. Filtering by specific labels

SELECT

distributed_statement_id,

login_name,

label,

allocated_cpu_time_ms

FROM

queryinsights.exec_requests_history

WHERE

label = ‘Data Load’

ORDER BY

allocated_cpu_time_ms DESC;

This query focuses on queries labeled as ‘Data Load’, helping teams isolate performance metrics related to ETL processes.

Becoming a Fabric Data Warehouse performance detective

To excel in optimizing your Fabric Data Warehouse, consider the following steps:

  1. Regular evaluation: Consistently review Query Insights to stay informed about query performances and system health.
  2. Identify bottlenecks: Focus on long running and frequently executed queries to uncover and address performance hindrances.
  3. Analyze CPU usage & caching: Utilize resource metrics like CPU time and data scanned to identify inefficiencies.
  4. Use labels effectively: Leverage query labels to categorize and analyze performance trends across different workloads.
  5. Leverage Query Hash: Use query_hash to group similar queries and identify optimization opportunities.
  6. Engage with the Community: Participate in forums and discussions to share experiences and learn from peers. Platforms like Reddit’s r/MicrosoftFabric offer valuable insights and collaborative opportunities.

By leveraging Query Insights, you transform into a performance detective, uncovering inefficiencies and implementing solutions that enhance the overall effectiveness of your data warehouse operations.

Related blog posts

Unlock the Power of Query insights and become a Fabric Data Warehouse performance detective

April 17, 2025 by Jovan Popovic

The BULK INSERT statement is generally available in Fabric Data Warehouse. The BULK INSERT statement enables you to ingest parquet or csv data into a table from the specified file stored in Azure Data Lake or Azure Blob storage: The BULK INSERT statement is very similar to the COPY INTO statement and enables you to … Continue reading “BULK INSERT statement is generally available!”

April 8, 2025 by Meenal Srivastva

We are excited to announce the latest update to our permission model for OneLake events in the Fabric Real-Time Hub. Previously, users with the ReadAll permission, such as workspace admins, members, and contributors, could subscribe to OneLake events for items like lakehouses, warehouses, SQL databases, mirrored databases, and KQL databases. To provide more granular control, we … Continue reading “Announcing permission model changes for OneLake events in Fabric Real-Time Hub”