agentleFS
wardawgmalviciouswardawgmalvicious/agent-config/skills/fabric-engineering/fabric-warehouse-monitoring/SKILL.md

fabric-warehouse-monitoring

Skill1 starsChanged 35 days agoMITView on GitHub

Use for monitoring Fabric Warehouse queries — OPTION (LABEL = '...') for tracking, the queryinsights schema (exec_requests_history, exec_sessions_history, long_running_queries, frequently_run_queries), 30-day retention, 15-minute appearance lag, the `Invalid object name` gotcha on newly-created warehouses, and diagnosing slow/stale Lakehouse SQLEP reads under the new metadata-sync preview (`sys.dm_db_external_tables_log_status`, `sp_dw_refresh_ext_table`).

  • Deletes or force-pushes

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Gotcha: After a rolled-back transaction containing a large INSERT, auto-generated statistics can be inaccurate.

    line 126

≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Monitoring & diagnostics

Query Labels

SELECT ... FROM ...
OPTION (LABEL = 'PROJECT_Module_Description');

Labels appear in queryinsights.exec_requests_history.label. Use for tracking, filtering, and performance analysis.

Query Insights (30-day retention)

ViewPurpose
queryinsights.exec_requests_historyEvery completed query: status, duration, CPU, data scanned
queryinsights.exec_sessions_historySession history: login info, times
queryinsights.long_running_queriesAggregated: median vs last-run time
queryinsights.frequently_run_queriesRun counts, execution times for recurring patterns

Gotcha: Data appears with up to 15 minutes delay. After creating a new warehouse, views may return "Invalid object name" — wait ~2 minutes.

Top Expensive Queries

SELECT TOP 10
    distributed_statement_id, query_hash, label,
    total_elapsed_time_ms, allocated_cpu_time_ms,
    data_scanned_remote_storage_mb, result_cache_hit
FROM queryinsights.exec_requests_history
ORDER BY allocated_cpu_time_ms DESC;

Aggregate by query_hash over the last 7 days to find recurring expensive patterns.

To find the queries behind a Capacity Metrics billing interval, correlate by time, not by ID: the Metrics app's Operation Id no longer maps to distributed_statement_id (Learn, confirmed 2026-09-11). Take the interval's Start and End from the app's Background operations table, then select the requests that overlapped it:

DECLARE @Start_Time DATETIME2(0) = '2026-08-04 8:00:00'
        ,@End_Time DATETIME2(0) = '2026-08-04 9:00:00'

SELECT [database_name],
       sql_pool_name,
       distributed_statement_id,
       login_name,
       allocated_cpu_time_ms / 1000.0 AS vcore_seconds
FROM queryinsights.exec_requests_history
WHERE start_time < @End_Time
AND end_time > @Start_Time;

DMVs (Live State)

DMVShowsMin Role
sys.dm_exec_connectionsActive connections (session_id, client_address)Admin only
sys.dm_exec_sessionsAuthenticated sessions (login_name, login_time, status)All roles (own sessions)
sys.dm_exec_requestsActive requests (command, start_time, total_elapsed_time)All roles (own requests)
-- Find long-running queries
SELECT request_id, session_id, command, start_time, total_elapsed_time, status
FROM sys.dm_exec_requests
WHERE status = 'running'
ORDER BY total_elapsed_time DESC;

-- Identify the user
SELECT login_name FROM sys.dm_exec_sessions WHERE session_id = <id>;

-- Kill a runaway query (Admin only)
KILL '<session_id>';

SQL Endpoint Metadata Sync (new sync — Preview, May 2026)

Diagnose slow/stale Lakehouse SQLEP reads when queries return data older than what has landed. On endpoints created under the new metadata-sync preview (opt-in, new endpoints only):

-- Inspect per-table sync freshness and blocked state
SELECT last_update_time_utc, latest_log_version, latest_checkpoint_version, is_blocked
FROM sys.dm_db_external_tables_log_status;   -- is_blocked: 1 = last update blocked, 0 = succeeded

-- Force a targeted refresh of one table's data (data-only changes)
EXEC sys.sp_dw_refresh_ext_table 'dbo.<table>';

Schema changes (add/drop tables or columns, type changes) need the full-item Refresh SQL endpoint metadata REST API instead. Full preview note — enablement, architecture, limitations — lives in the fabric-spark skill; the slow-SQLEP gotcha cross-references it in the fabric-rest-api skill's references/gotchas.md.

Result Set Caching

On by default for every Warehouse and Lakehouse SQL analytics endpoint (GA; Learn and What's New, checked 2026-10-06). A known issue reported it disabled as of 2026-09-11; whether that issue is closed was not confirmed on 2026-10-06, so check the setting before relying on the default:

-- Is it on for the connected item?
SELECT name, is_result_set_caching_on
FROM sys.databases
WHERE database_id = db_id();

-- Turn it off for the item
ALTER DATABASE <Fabric_item_name>
SET RESULT_SET_CACHING OFF;

-- Or for one query, e.g. to debug or A/B test it
SELECT ... FROM ...
OPTION ( USE HINT ('DISABLE_RESULT_SET_CACHE') );

result_cache_hit field in exec_requests_history: 2 = cache hit, 1 = the query created the cache, 0 = not applicable for cache creation or use. Learn documents only these three values.

Only a pure SELECT qualifies, and Learn lists 15 disqualifiers. The ones that bite most often: a result estimated above 10,000 rows; no referenced table of at least 100,000 rows; a cross-database reference; runtime constants (GETDATE(), CURRENT_USER), non-deterministic functions, window aggregates or PARTITION BY … ORDER BY; row-level security, dynamic data masking or another security feature; time travel; an explicit transaction or WHILE loop; a session with non-default SET options. Any change to a referenced table invalidates the cache, and a cache goes unused after 24 hours idle, or from a different connection, column list or alias set.

Statistics

Auto-maintained for single-column histograms, average column length, and table cardinality. Manual CREATE STATISTICS / UPDATE STATISTICS available.

Gotcha: After a rolled-back transaction containing a large INSERT, auto-generated statistics can be inaccurate. Run UPDATE STATISTICS manually on affected columns to recover.

Reference

See also

  • fabric-warehouse skill — T-SQL authoring rules for the queries you're monitoring
  • fabric-rest-api skill — the cross-cutting error index, in its references/gotchas.md

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.