plugins/fabric-operations/skills/sqldb-operations-cli/SKILL.md
Diagnose SQL database in Fabric performance via sqlcmd against Query Store, DMVs, sys.dm_db_resource_stats, and Extended Events on the OLTP endpoint. Identifies the top resource-consuming, slowest, or most expensive queries and handles query-performance ranking, blocking-chain, missing-index, and plan-regression diagnostics. For routine data queries use the sqldb-consumption-cli skill; for schema changes use the sqldb-authoring-cli skill. Triggers: "query store slow query analysis sqldb top queries", "top resource-consuming queries from query store sqldb", "slowest queries sql database in Fabric query store", "most expensive queries sqldb query store", "sql database in Fabric blocked sessions head blocker chain sqlcmd", "sqldb missing index recommendation", "sqldb regressed plan instability sqlcmd", "sqldb extended events trace".
npx skillsauth add microsoft/skills-for-fabric sqldb-operations-cliInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Update Check — ONCE PER SESSION (mandatory) The first time this skill is used in a session, run the check-updates skill before proceeding.
- GitHub Copilot CLI / VS Code: invoke the
check-updatesskill.- Claude Code / Cowork / Cursor / Windsurf / Codex: compare local vs remote package.json version.
- Skip if the check was already performed earlier in this session.
CRITICAL NOTES
- To find the workspace details (including its ID) from workspace name: list all workspaces and, then, use JMESPath filtering
- To find the item details (including its ID) from workspace ID, item type, and item name: list all items of that type in that workspace and, then, use JMESPath filtering
Deep performance diagnostics for SQL database in Fabric via sqlcmd against Query Store, DMVs, sys.dm_db_resource_stats, and Extended Events. All analytical queries are read-only; the optional XE session creation is dropped at the end of the investigation.
VIEW DATABASE STATE for DMVs; ALTER ANY EVENT SESSION to create XE sessions.| Topic | Reference | |---|---| | Finding Workspaces and Items in Fabric | COMMON-CLI.md § Finding Workspaces and Items in Fabric — read first | | SQL / TDS Data-Plane Access (sqlcmd, auth) | COMMON-CLI.md § SQL / TDS Data-Plane Access | | CLI Gotchas (audience, escaping, expiry) | COMMON-CLI.md § Gotchas & Troubleshooting | | Endpoint Selection (use OLTP) | SQLDB-CONSUMPTION-CORE.md § Endpoint Selection | | Performance and Monitoring foundations | SQLDB-CONSUMPTION-CORE.md § Performance and Monitoring | | Limitations Reference (unsupported features, DMVs) | SQLDB-AUTHORING-CORE.md § Limitations Reference | | Mirroring Considerations | SQLDB-AUTHORING-CORE.md § Mirroring Considerations | | All diagnostic T-SQL | references/query-reference.md | | Investigation Workflows | SKILL.md § Investigation Workflows | | Examples | references/examples.md |
For Fabric topology, capacity, and platform auth basics see COMMON-CORE.md.
Diagnostics run against the SQL database (OLTP) endpoint. For endpoint discovery, authentication, and sqlcmd connection guidance, use the shared CLI instructions in COMMON-CLI.md rather than inline setup here.
Once connected, use the diagnostic workflows below and the full T-SQL catalog in query-reference.md.
All SQL is in query-reference.md. Step-by-step orchestration in Investigation Workflows below.
sys.sp_query_store_force_plan is supported but use sparingly; auto-tuning may correct over time.avg_cpu_percent ≥ 80 over 10 min = sustained; non_cpu_to_cpu_ratio > 5 = waiting on resources, not CPU-bound.avg_data_io_percent ≥ 80 (data); avg_log_write_percent ≥ 80 (log, often un-batched DML).sys.dm_db_resource_stats retains only 1 hour of 15-second samples; persist or use Query Store for longer windows.Optimized locking is on by default — no traditional lock escalation. Most blocking comes from long-running transactions, app-side held transactions, or hot-row contention.
open_transaction_count > 0 → application is holding an open transaction; fix client code.ON DATABASE only (not ON SERVER); use ring_buffer target. Always clean up.index_advantage = user_seeks * avg_total_user_cost * (avg_user_impact * 0.01). DMV stats reset on restart.≥ 100,000 rows and ≥ 10% modification.Step-by-step orchestration. Each step links to the corresponding query in query-reference.md.
open_transaction_count, SQL text, program_name.open_transaction_count > 0 → application bug; fix client code (uncommitted transaction).Full list of unsupported features: SQLDB-AUTHORING-CORE.md § Limitations Reference. Operations-critical items:
| Do NOT Recommend | Why | Recommend Instead |
|---|---|---|
| Server-scoped DMVs (sys.dm_os_*, sys.configurations) | Not exposed | sys.dm_db_resource_stats, Query Store views |
| EXECUTE AS for security testing | Not supported | Connect as the actual user identity |
| CREATE EVENT SESSION ... ON SERVER, file-target XE | Database-scoped only | ... ON DATABASE with ring_buffer target |
| Trace flags / DBCC TRACEON | Not supported | Re-architect query or use Query Store hints |
| Manual lock escalation tuning | Optimized locking eliminates escalation | Address root cause (long transactions, hot rows) |
| SQL analytics endpoint for diagnostics | DMVs/Query Store don't exist there | Connect to the SQL database (OLTP) endpoint |
| Aggressive sp_query_store_force_plan | Masks root cause | Fix stats / parameter sniffing first; force only as a stop-gap |
For consumption foundations see SQLDB-CONSUMPTION-CORE.md § Performance and Monitoring.
DATEADD lookback windows to the user's investigation scope.sys.dm_db_resource_stats if you need > 1 hour of history.CLI/auth issues: COMMON-CLI.md § Gotchas. Platform issues: SQLDB-CONSUMPTION-CORE.md § Gotchas.
-i file.sql for the XE session creation block (here-doc has portability quirks).SET NOCOUNT ON; at the top of multi-statement scripts to keep CSV output clean.sp_query_store_force_plan instead of fixing root cause.| Symptom | Cause | Fix |
|---|---|---|
| Invalid object name 'sys.query_store_*' | Querying analytics endpoint | Connect to OLTP endpoint |
| Volatile detection returns no rows | Lookback too short / no recent activity | Expand DATEADD(MINUTE, -60, ...) to -1440 |
| sys.dm_db_resource_stats empty | Lookback exceeds 1-hour retention | Reduce window; or use Query Store |
| Permission error on DMVs | Missing VIEW DATABASE STATE | GRANT VIEW DATABASE STATE TO [[email protected]] |
| Permission error on CREATE EVENT SESSION | Missing ALTER ANY EVENT SESSION | GRANT ALTER ANY EVENT SESSION TO [[email protected]] |
| XE session captures nothing | LIKE filter too narrow / session in STOP state | Check sys.dm_xe_database_sessions.state; widen filter |
| Multi-plan query has no obvious bad plan | Parameter sniffing | OPTION (RECOMPILE) or OPTIMIZE FOR hint |
See references/examples.md for full prompt/response patterns covering:
tools
Manages Fabric Spark work, including notebook cell code with %%configure, %%sql, PySpark and notebookutils, named notebook runs, Livy sessions, triage of failed or OOM notebook and pipeline Spark runs, and the Materialized Lake View (MLV) lifecycle. Load it before writing MLV SQL, since CREATE MATERIALIZED LAKE VIEW and its CONSTRAINT clause are Fabric-only. KQL materialized views belong to eventhouse-cli.
tools
Governs Microsoft Fabric OneLake catalog health, protection, and trust through Fabric Admin, Core, and Power BI REST APIs. Use for tenant or owner-scoped audits and guarded remediation of domains, workspace assignment, capacity, labels, tags, descriptions, refresh, and item identity. Catalog item discovery belongs to search-consumption-cli.
tools
Runs the Fabric Git integration lifecycle through fab api or az rest, including connecting a workspace to Azure DevOps or GitHub, committing, updating from Git, reading sync status, resolving conflicts, disconnecting a connected workspace, and automating sync with a service principal. For stage promotion use deployment-pipelines-authoring-cli. Branch switching, fab deploy, fabric-cicd and cross-workspace rebinding are out of scope.
tools
Manages Fabric IQ Ontology items, including entity and relationship types, data bindings, and definition updates, plus schema, lineage, grounding, and graph-walk exploration. Use for ontology modelling and traversal. For natural-language questions over a Power BI report use fabriciq.