Skip to main content

Performance Monitoring & Tuning

Not sure which monitoring tool to use? See the Monitoring Tools Matrix for a complete comparison of Query Store, DMVs, Extended Events, and Azure-native tools.

The Monitoring Mental Model​

Detect β†’ Diagnose β†’ Fix
πŸ”
1. Detect
Azure Portal Metrics (CPU%, DTU%)
Azure Monitor Alerts
Query Performance Insight
🩺
2. Diagnose
Query Store (plan regressions)
DMVs (wait stats, sessions)
Intelligent Insights (ML anomaly)
πŸ› οΈ
3. Fix
Automatic Tuning (force plans)
Manual Index Tuning
Query Rewriting
Tier/Compute Scaling
🏒 Real-World DBA Note

Oracle DBA parallel: This is your OEM β†’ AWR β†’ ADDM β†’ SQL Tuning Advisor flow, but in Azure. Portal Metrics = OEM dashboard. Query Store = AWR. Intelligent Insights = ADDM. Automatic Tuning = SQL Profiles applied automatically.

Key Monitoring Signals​

MetricWhat It Tells YouOracle Equivalent
CPU %Query/index issuesCPU used by this session wait
Data IO %Storage bottleneck, missing indexesdb file sequential/scattered read
Log IO %Write-heavy workload, log rate limitlog file sync
DTU %Overall resource saturation (DTU model)Top-N AWR metrics combined
Sessions/Workers %Connection pool exhaustionv$session active count
DeadlocksConcurrent access conflictsORA-00060

Query Store β€” Your Flight Recorder​

The most important tool for DP-300. Think of it as AWR on steroids β€” it captures per-query plans and stats continuously.

What Query Store Captures​

DataRetentionOracle Equivalent
Query textUntil purgedV$SQL
Execution plans (all historical)ConfigurableDBA_HIST_SQL_PLAN
Runtime stats (CPU, duration, reads, rows)ConfigurableDBA_HIST_SQLSTAT
Wait statistics per queryConfigurableV$SESSION_WAIT + ASH
Plan forcing informationUntil removedSQL Profiles / SQL Baselines

Query Store Architecture​

Query Store Architecture
Query Store Architecture
✈️
Flight Recorder
Captures every query text, execution plan, and runtime stats continuously
πŸ“Š
Plan + Stats Storage
Stores all historical plans + CPU, duration, reads, rows per query. Configurable retention.
πŸ”„
Plan Forcing
Force a specific plan when regression detected. FORCE_LAST_GOOD_PLAN auto-reverts bad plans.
🎯 Exam Focus

Query Store exam facts: 1) Enabled by default in Azure SQL DB. 2) Must be manually enabled on SQL Server/VM. 3) You can force a specific plan (like Oracle SQL Profiles). 4) It detects plan regressions automatically. 5) Stores data in the user database (not system DB).

The "Regressed Queries" Pattern (Exam Favorite)​

  1. A query runs fine for months with Plan A
  2. Statistics update or schema change β†’ optimizer picks Plan B
  3. Plan B is slower β†’ performance regression
  4. Query Store detects this and can auto-force Plan A back

This is FORCE_LAST_GOOD_PLAN in Automatic Tuning β€” Azure's equivalent of Oracle's SQL Plan Baseline.

Dynamic Management Views (DMVs) β€” Cheat Sheet​

What You NeedDMVOracle Equivalent
Currently running queriessys.dm_exec_requests + sys.dm_exec_sql_text()V$SESSION + V$SQL
Top queries by CPUsys.dm_exec_query_statsV$SQL ORDER BY CPU_TIME
Missing indexessys.dm_db_missing_index_*DBA_ADVISOR_RECOMMENDATIONS
Index fragmentationsys.dm_db_index_physical_stats()INDEX_STATS / ANALYZE INDEX VALIDATE
Wait statisticssys.dm_os_wait_statsV$SESSION_WAIT / ASH
Resource usage (last 1 hr)sys.dm_db_resource_statsV$SYSMETRIC
Active sessionssys.dm_exec_sessionsV$SESSION
Blocking chainssys.dm_exec_requests (blocking_session_id)V$LOCK + DBA_BLOCKERS
🎯 Exam Focus

Most-tested DMVs: sys.dm_db_resource_stats (resource utilization), sys.dm_exec_query_stats (query performance), sys.dm_db_missing_index_details (missing indexes), and sys.dm_db_index_physical_stats (fragmentation).

Index Tuning β€” Architecture & Strategy​

Index Types​

TypeArchitectureBest ForOracle Equivalent
ClusteredIS the table (data sorted by key)Primary key, range queriesIndex-Organized Table (IOT)
Non-clusteredSeparate B-tree with pointers to dataLookups, filtered queriesRegular B-tree index
ColumnstoreColumn-based storage, high compressionAnalytics, aggregationsNo direct equivalent (closest: bitmap)
FilteredNC index with WHERE clauseSparse data, status columnsFunction-based index (partial)

Index Maintenance Decision Tree​

Index Maintenance Decision
πŸ”
Check Fragmentation
sys.dm_db_index_physical_stats()
Measure avg_fragmentation_in_percent
βœ…
< 10%: No Action
Fragmentation is negligible
No maintenance needed
πŸ”§
10-30%: REORGANIZE
Online operation, no locks
Lightweight defragmentation
πŸ› οΈ
> 30%: REBUILD
Full rebuild of B-tree structure
Use ONLINE = ON in production
⚠️ Watch Out

REBUILD locks the table by default (offline). Always use ALTER INDEX ... REBUILD WITH (ONLINE = ON) in production. This requires Enterprise edition on VMs, but is always available in Azure SQL DB and MI (which include Enterprise features).

Columnstore β€” The Analytics Superpower​

Columnstore vs Rowstore
πŸ“„
Rowstore (Traditional)
Stores entire rows together. Fast for point lookups + OLTP. SUM(Amount) reads ALL columns.
πŸ“Š
Columnstore (Analytics)
Stores columns separately. SUM(Amount) reads ONLY that column. 10x compression, massive I/O savings.

Why columnstore is fast for analytics: SUM(Amount) only reads the Amount column (not entire rows). Compression can be 10x+, reducing I/O dramatically. Perfect for GROUP BY, SUM, AVG, COUNT on large datasets.

Automatic Tuning β€” Azure's Self-Healing​

OptionWhat It DoesDefault
FORCE_LAST_GOOD_PLANDetects plan regression β†’ forces previous good planβœ… On (Azure SQL DB)
CREATE_INDEXCreates missing indexes based on DMV recommendations❌ Off (opt-in)
DROP_INDEXDrops unused indexes wasting storage/write overhead❌ Off (opt-in)
🎯 Exam Focus

FORCE_LAST_GOOD_PLAN is the only automatic tuning option enabled by default. CREATE_INDEX and DROP_INDEX must be explicitly enabled. The exam tests whether you know which are on vs off by default.

Intelligent Insights​

ML-based performance analysis that detects:

  • Timeout increasing β€” queries timing out more frequently
  • Waiting increasing β€” specific wait types growing
  • Regression β€” queries getting slower over time
  • Tempdb contention β€” excessive tempdb usage impacting performance

Results are written to a diagnostics log in JSON format β†’ viewable in Azure Portal or Log Analytics.

🏒 Real-World DBA Note

Think of Intelligent Insights as ADDM that runs continuously. Oracle ADDM analyzes AWR snapshots hourly. Intelligent Insights analyzes Query Store + metrics continuously and proactively alerts on anomalies. No manual AWR report generation needed.


Anti-Patterns​

  • "Trust Automatic Tuning blindly on prod." Plan correction (FORCE_LAST_GOOD_PLAN) is generally safe; auto-create / auto-drop indexes can be risky on write-heavy or schema-frozen apps. Audit recommendations first, then enable per-action.
  • "Disable Query Store β€” it costs storage." Default 100 MB / 1 GB cap is trivial. Disabling QS removes Intelligent Insights, plan forcing, regression detection, and most performance reports. Almost always the wrong call.
  • "Bigger DTU/vCore β†’ fixes the slow query." Sometimes (CPU-bound). Often masks the root cause. Always check wait stats + plan before scaling. Scaling is the fastest and most expensive lever.
  • "Resource Governor doesn't apply on Azure SQL DB." Correct β€” it's MI / SQL VM only. Apps that depend on RG must move to MI when migrating from on-prem.
  • "sp_who2 and DBCC OPENTRAN are enough." They show now. For trend-aware tuning use sys.dm_exec_query_stats, Query Store, sys.dm_db_wait_stats (DB-level on Azure SQL DB), and Intelligent Insights.
  • "Index suggestions in the portal β€” just apply them all." Same trap as sys.dm_db_missing_index_*. Each is per-query; multiple may overlap; some increase write cost. Review before applying.
⚠️ Watch Out

Query Store survives planned failover and PITR restore but NOT a schema-only deployment that drops/recreates the DB. If your CI/CD does drop+create, all QS history is lost. Use ALTER scripts.


Migration Between Tuning Strategies​

From β†’ ToPathCost
Manual plan tuning β†’ Automatic Tuning (FORCE_LAST_GOOD_PLAN)Toggle at server / DB levelFree; reduces incident response time
Manual indexing β†’ Automatic Tuning (CREATE_INDEX)Toggle; review log of changesAuto-acts on dm_db_missing_index_*; risk on write-heavy workloads
Query Store off β†’ on (on-prem SQL Server)ALTER DATABASE ... SET QUERY_STORE = ONSmall storage; gains plan history
Reactive tuning β†’ Intelligent InsightsBuilt-in on Azure SQL DB/MI; review JSON in DiagnosticsFree; alerts via Azure Monitor on top
sp_who2 polling β†’ Database WatcherWatcher captures wait stats + blockingCross-server view; ADX cost
Performance Insight (deprecated) β†’ Query Performance Insight + QSUse new portal bladeSame QS data, better visualization
DTU model β†’ vCore (for tuning visibility)Scale tier; vCore exposes per-resource governorOne-time scale; gain transparent metrics
Resource Governor on SQL VM β†’ MI workload group equivalentsMove to MI; reconfigure resource poolsArchitecture change; most apps fit MI

Most expensive moves: enabling Automatic Tuning CREATE_INDEX on a write-heavy DB without review, and DTU β†’ vCore migration if it requires app reconfig.


Real Scenarios​

  1. Production hit by a regressed plan after stats refresh β†’ Query Store β†’ Regressed Queries β†’ Force previous plan. Driver: minutes-to-recovery. Trade-off: forced plans persist until reviewed.
  2. Cost spike on Azure SQL DB β†’ Query Performance Insight β†’ top CPU consumers + DTU/vCore consumption chart. Driver: identify the query, not just the spike. Trade-off: requires QS on.
  3. Greenfield app, want β€˜set and forget’ β†’ Automatic Tuning all options on for first 90 days; review the change log; selectively disable. Driver: lowest manual effort. Trade-off: must read the audit trail.
  4. MI hosting ISV ERP, Resource Governor required β†’ MI workload management with workload groups + classifier. Driver: per-app CPU/IO caps. Trade-off: classifier maintenance.
  5. DBA team learning Azure tuning β†’ Query Store + Database Watcher + Intelligent Insights JSON β†’ LA + Workbook. Driver: build the muscle. Trade-off: tooling sprawl until stack standardized.

Flashcards​

What is Query Store?
Click to reveal answer
A 'flight recorder' that captures query execution plans, runtime statistics, and history. Enables plan forcing and regression detection.
1 / 7

Quiz​

Q1/4
0 correct
A query's execution plan suddenly changed and performance dropped. Which tool best diagnoses this?