Queries¶
Inspect and manage running queries on Microsoft Fabric Data Warehouses and SQL Analytics Endpoints.
Targets: Data Warehouse / SQL Analytics Endpoint
CLI¶
queries connections¶
Targets: Data Warehouse / SQL Analytics Endpoint
List all active SQL connections on a warehouse or SQL Analytics Endpoint. This queries sys.dm_exec_connections and shows lower-level connection info (including idle connections) that is not visible in queries running.
Synopsis
| Option | Description |
|---|---|
--watch SECONDS |
Refresh the live view every positive number of seconds. Cannot be combined with --json. |
Example
session_id connect_time client_net_address auth_scheme encrypt_option net_transport most_recent_session_id
---------- -------------------- ------------------ ----------- -------------- ------------- ----------------------
10 2026-06-08T10:00:00Z 192.168.1.100 NTLM TRUE TCP 10
20 2026-06-08T10:01:00Z 192.168.1.101 KERBEROS FALSE TCP 20
queries frequent¶
Targets: Data Warehouse / SQL Analytics Endpoint
List frequently-run queries from queryinsights.frequently_run_queries.
Note: Elapsed-time fields (e.g.
avg_total_elapsed_time_ms,min_run_total_elapsed_time_ms,max_run_total_elapsed_time_ms,last_run_total_elapsed_time_ms) are typed asfloat(numberin JSON) because Fabric returns fractional millisecond values. Count fields (number_of_runs,number_of_successful_runs,number_of_failed_runs,number_of_canceled_runs) remainint.
Synopsis
| Option | Description | Default |
|---|---|---|
--limit INTEGER |
Maximum rows to return (1–10 000). | 100 |
--since ISO8601 |
Return rows with last_run_start_time >= this value. Mutually exclusive with --ago. |
- |
--until ISO8601 |
Return rows with last_run_start_time <= this value. | - |
--ago DURATION |
Relative alternative to --since: rows newer than now minus this duration (e.g. 1h, 90m, 3600s, 2d). Mutually exclusive with --since. |
- |
Example
fdw -w MyWorkspace queries frequent SalesWH --limit 20
fdw -w MyWorkspace queries frequent SalesWH --ago 1h
queries history¶
Targets: Data Warehouse / SQL Analytics Endpoint
List completed SQL requests from queryinsights.exec_requests_history. Supports optional time-range filtering with --since and --until (ISO-8601 strings). The --limit option caps the number of rows returned (default: 100, max: 10 000).
Note: Elapsed-time and CPU-time fields (e.g.
total_elapsed_time_ms,allocated_cpu_time_ms) are typed asfloat(numberin JSON) because Fabric returns fractional millisecond values. Count fields (e.g.row_count) remainint.
Synopsis
| Option | Description | Default |
|---|---|---|
--limit INTEGER |
Maximum rows to return (1–10 000). | 100 |
--since ISO8601 |
Return rows with timestamp >= this value. Mutually exclusive with --ago. |
- |
--until ISO8601 |
Return rows with timestamp <= this value. | - |
--ago DURATION |
Relative alternative to --since: rows newer than now minus this duration (e.g. 1h, 90m, 3600s, 2d). Mutually exclusive with --since. |
- |
Example
fdw -w MyWorkspace queries history SalesWH --limit 50 --since 2026-06-01T00:00:00
fdw -w MyWorkspace queries history SalesWH --ago 1h
queries kill¶
Targets: Data Warehouse / SQL Analytics Endpoint
Kill a specific session on a warehouse or SQL Analytics Endpoint. You will be asked to confirm unless --yes is passed.
Synopsis
Example
queries locks¶
Targets: Data Warehouse / SQL Analytics Endpoint
List active locks from sys.dm_tran_locks, joined with sys.dm_exec_requests to show blocking info. DATABASE-scoped rows are excluded by default to reduce noise from idle connections.
Synopsis
| Option | Description | Default |
|---|---|---|
--limit INTEGER |
Maximum rows to return (1-10 000). | 100 |
--waiting-only |
Only show locks with request_status in WAIT or CONVERT (includes lock-upgrade waits). |
off |
--blocked-only |
Only show sessions blocked by another session (victims). The blocker's ID appears in blocking_session_id. |
off |
--include-database |
Include DATABASE-scoped lock rows. | off |
--watch SECONDS |
Refresh the live view every positive number of seconds. Cannot be combined with --json. |
- |
Example
fdw -w MyWorkspace queries locks SalesWH
fdw -w MyWorkspace queries locks SalesWH --waiting-only
fdw -w MyWorkspace queries locks SalesWH --blocked-only --limit 50
queries long-running¶
Targets: Data Warehouse / SQL Analytics Endpoint
List long-running queries from queryinsights.long_running_queries.
Note:
median_total_elapsed_time_msandlast_run_total_elapsed_time_msare typed asfloat(numberin JSON) because Fabric returns fractional millisecond values.number_of_runsremainsint.
Synopsis
| Option | Description | Default |
|---|---|---|
--limit INTEGER |
Maximum rows to return (1–10 000). | 100 |
--since ISO8601 |
Return rows with last_run_start_time >= this value. Mutually exclusive with --ago. |
- |
--until ISO8601 |
Return rows with last_run_start_time <= this value. | - |
--ago DURATION |
Relative alternative to --since: rows newer than now minus this duration (e.g. 1h, 90m, 3600s, 2d). Mutually exclusive with --since. |
- |
Example
fdw -w MyWorkspace queries long-running SalesWH
fdw -w MyWorkspace queries long-running SalesWH --ago 2d
queries running¶
Targets: Data Warehouse / SQL Analytics Endpoint
List all currently running queries on a warehouse or SQL Analytics Endpoint. Queries sys.dm_exec_sessions joined with sys.dm_exec_requests. Use dist_statement_id with queries show to retrieve the full query text and execution metrics after the query completes.
Synopsis
| Option | Description |
|---|---|
--watch SECONDS |
Refresh the live view every positive number of seconds. Cannot be combined with --json. |
Example
session_id status total_elapsed_time login_name command dist_statement_id cpu_time reads logical_reads row_count
---------- ------- ------------------ ----------- ------- ------------------------------------ -------- ----- ------------- ---------
42 running 1500 user@co.io SELECT A1B2C3D4-1234-5678-ABCD-EF012345678 750 100 1000 50
queries sessions¶
Targets: Data Warehouse / SQL Analytics Endpoint
List completed sessions from queryinsights.exec_sessions_history.
Note:
total_query_elapsed_time_msis typed asfloat(numberin JSON) because Fabric returns fractional millisecond values.
Synopsis
| Option | Description | Default |
|---|---|---|
--limit INTEGER |
Maximum rows to return (1–10 000). | 100 |
--since ISO8601 |
Return rows with session_start_time >= this value. Mutually exclusive with --ago. |
- |
--until ISO8601 |
Return rows with session_start_time <= this value. | - |
--ago DURATION |
Relative alternative to --since: rows newer than now minus this duration (e.g. 1h, 90m, 3600s, 2d). Mutually exclusive with --since. |
- |
Example
queries show¶
Targets: Data Warehouse / SQL Analytics Endpoint
Look up a single completed query by its distributed_statement_id from queryinsights.exec_requests_history. Use the dist_statement_id returned by queries running to retrieve the full query text and execution metrics.
See the Fabric Query Insights documentation for more details.
Synopsis
Example
MCP tools¶
The tools below cover running queries, active connections, locks, and queryinsights history. History tools share the same parameter shape: workspace, warehouse, optional limit, optional since, and optional until.
get_request_detail¶
Targets: Data Warehouse / SQL Analytics Endpoint
Look up a single completed query from queryinsights.exec_requests_history by its distributed_statement_id. Use the dist_statement_id returned by list_running_queries to retrieve full query text and execution metrics after the query completes.
See the Fabric Query Insights documentation for details on the queryinsights schema and required permissions.
Parameters:
workspace(str): workspace name or GUID.item(str): warehouse or SQL Analytics Endpoint name or GUID.dist_statement_id(str): thedistributed_statement_idGUID to look up.
Returns: dict | null: the matching request-history row as a dict (same schema as list_request_history rows), or null if no matching row exists.
kill_session¶
Targets: Data Warehouse / SQL Analytics Endpoint
Terminate a session on a warehouse.
Parameters:
workspace(str): workspace name or GUID.warehouse(str): warehouse name or GUID.session_id(int): the session ID to terminate.
Returns: { "killed": true, "session_id": int }: confirmation with the terminated session ID.
list_connections¶
Targets: Data Warehouse / SQL Analytics Endpoint
Return all active SQL connections on a warehouse or SQL Analytics Endpoint. Queries sys.dm_exec_connections, which includes idle connections not visible via list_running_queries.
Parameters:
workspace(str): workspace name or GUID.warehouse(str): warehouse name or GUID.
Returns: list[Connection]: array of connection objects, each with session_id, connect_time, client_net_address, auth_scheme, encrypt_option, and net_transport.
list_frequent_queries¶
Targets: Data Warehouse / SQL Analytics Endpoint
Return frequently-run queries from queryinsights.frequently_run_queries.
Parameters:
workspace(str): workspace name or GUID.warehouse(str): warehouse or SQL Analytics Endpoint name or GUID.limit(int, default100): maximum rows to return (1–10 000).since(str | null, optional): ISO-8601 lower bound onlast_run_start_time.until(str | null, optional): ISO-8601 upper bound onlast_run_start_time.
Returns: list[dict]: array of frequently-run query row objects. Elapsed-time fields (e.g. avg_total_elapsed_time_ms, min_run_total_elapsed_time_ms, max_run_total_elapsed_time_ms, last_run_total_elapsed_time_ms) are JSON number (float); count fields remain integer.
list_locks¶
Targets: Data Warehouse / SQL Analytics Endpoint
Return active lock rows from sys.dm_tran_locks joined with sys.dm_exec_requests. DATABASE-scoped rows are excluded by default.
Parameters:
workspace(str): workspace name or GUID.item(str): warehouse or SQL Analytics Endpoint name or GUID.limit(int, default100): maximum rows to return (1-10 000).waiting_only(bool, defaultfalse): restrict to locks withrequest_statusinWAITorCONVERT(includes lock-upgrade waits).blocked_only(bool, defaultfalse): restrict to sessions blocked by another session (victims); the blocker's ID appears inblocking_session_id.include_database(bool, defaultfalse): include DATABASE-scoped lock rows.
Returns: list[dict]: array of lock row objects, each with session_id, resource_type, request_mode, request_status, schema_name, object_name, blocking_session_id, wait_type, wait_time (ms), and command.
list_long_running_queries¶
Targets: Data Warehouse / SQL Analytics Endpoint
Return long-running queries from queryinsights.long_running_queries.
Parameters:
workspace(str): workspace name or GUID.warehouse(str): warehouse or SQL Analytics Endpoint name or GUID.limit(int, default100): maximum rows to return (1–10 000).since(str | null, optional): ISO-8601 lower bound onlast_run_start_time.until(str | null, optional): ISO-8601 upper bound onlast_run_start_time.
Returns: list[dict]: array of long-running query row objects. median_total_elapsed_time_ms and last_run_total_elapsed_time_ms are JSON number (float); number_of_runs remains integer.
list_request_history¶
Targets: Data Warehouse / SQL Analytics Endpoint
Return completed SQL requests from queryinsights.exec_requests_history.
Parameters:
workspace(str): workspace name or GUID.warehouse(str): warehouse or SQL Analytics Endpoint name or GUID.limit(int, default100): maximum rows to return (1–10 000).since(str | null, optional): ISO-8601 lower bound onsubmit_time.until(str | null, optional): ISO-8601 upper bound onsubmit_time.
Returns: list[dict]: array of request-history row objects. Elapsed-time and CPU-time fields (e.g. total_elapsed_time_ms, allocated_cpu_time_ms) are JSON number (float) because Fabric returns fractional millisecond values.
list_running_queries¶
Targets: Data Warehouse / SQL Analytics Endpoint
Return all currently-executing queries on a warehouse.
Parameters:
workspace(str): workspace name or GUID.warehouse(str): warehouse name or GUID.
Returns: list[RunningQuery]: array of query objects, each with session_id, request_id, status, start_time, total_elapsed_time (ms), login_name, command, dist_statement_id (for cross-tool correlation with Capacity Metrics and queryinsights - use with get_request_detail to retrieve full query text), blocking_session_id, wait_type, wait_time (ms), cpu_time (ms), reads, writes, logical_reads, row_count, and open_transaction_count.
list_session_history¶
Targets: Data Warehouse / SQL Analytics Endpoint
Return completed sessions from queryinsights.exec_sessions_history.
Parameters:
workspace(str): workspace name or GUID.warehouse(str): warehouse or SQL Analytics Endpoint name or GUID.limit(int, default100): maximum rows to return (1–10 000).since(str | null, optional): ISO-8601 lower bound onsession_start_time.until(str | null, optional): ISO-8601 upper bound onsession_start_time.
Returns: list[dict]: array of session-history row objects. total_query_elapsed_time_ms is JSON number (float) because Fabric returns fractional millisecond values.