πŸ”’ Guided

Pre-launch preview. Authorised access only.

Incorrect code

Guided by A Guide to Cloud
Explore AB-900 AI-901
Guided DP-800 Domain 2
Domain 2 β€” Module 5 of 11 45%
15 of 28 overall

DP-800 Study Guide

Domain 1: Design and Develop Database Solutions

  • Table Design: Columns, Types, and Indexes Free
  • Constraints: Protecting Your Data Free
  • Specialised Tables and Graph Queries Free
  • JSON in SQL: Store, Query, and Index
  • Programmability: Views, Functions, Procedures, and Triggers
  • Advanced T-SQL: CTEs, Windows, and Correlated Queries
  • Pattern Power: Regular Expressions in T-SQL
  • Fuzzy String Matching: Finding Similar Text
  • AI-Assisted SQL with GitHub Copilot Free
  • MCP: Connecting AI to Your Database

Domain 2: Secure, Optimize, and Deploy Database Solutions

  • Encryption: Always Encrypted and Column-Level
  • Dynamic Data Masking and Row-Level Security
  • Permissions, Auditing, and Passwordless Access
  • Transaction Isolation and Concurrency
  • Query Performance: Plans, DMVs, and Query Store
  • SQL Database Projects: Build and Validate
  • CI/CD Pipelines for SQL Databases
  • Data API Builder: REST and GraphQL from SQL
  • Securing AI and API Endpoints
  • Change Detection: CES, CDC, and Change Tracking
  • Azure Integration and Monitoring

Domain 3: Implement AI Capabilities in Database Solutions

  • External AI Models: Choose, Create, Manage
  • Embeddings: Design, Chunk, and Generate
  • Choose Your Search Strategy
  • Vector Data: Types, Indexes, and Storage
  • Vector Search: Distance, ANN, and ENN
  • Hybrid Search and Reciprocal Rank Fusion
  • RAG with SQL: Prompt, Process, Respond

DP-800 Study Guide

Domain 1: Design and Develop Database Solutions

  • Table Design: Columns, Types, and Indexes Free
  • Constraints: Protecting Your Data Free
  • Specialised Tables and Graph Queries Free
  • JSON in SQL: Store, Query, and Index
  • Programmability: Views, Functions, Procedures, and Triggers
  • Advanced T-SQL: CTEs, Windows, and Correlated Queries
  • Pattern Power: Regular Expressions in T-SQL
  • Fuzzy String Matching: Finding Similar Text
  • AI-Assisted SQL with GitHub Copilot Free
  • MCP: Connecting AI to Your Database

Domain 2: Secure, Optimize, and Deploy Database Solutions

  • Encryption: Always Encrypted and Column-Level
  • Dynamic Data Masking and Row-Level Security
  • Permissions, Auditing, and Passwordless Access
  • Transaction Isolation and Concurrency
  • Query Performance: Plans, DMVs, and Query Store
  • SQL Database Projects: Build and Validate
  • CI/CD Pipelines for SQL Databases
  • Data API Builder: REST and GraphQL from SQL
  • Securing AI and API Endpoints
  • Change Detection: CES, CDC, and Change Tracking
  • Azure Integration and Monitoring

Domain 3: Implement AI Capabilities in Database Solutions

  • External AI Models: Choose, Create, Manage
  • Embeddings: Design, Chunk, and Generate
  • Choose Your Search Strategy
  • Vector Data: Types, Indexes, and Storage
  • Vector Search: Distance, ANN, and ENN
  • Hybrid Search and Reciprocal Rank Fusion
  • RAG with SQL: Prompt, Process, Respond
Domain 2: Secure, Optimize, and Deploy Database Solutions Premium ⏱ ~14 min read

Query Performance: Plans, DMVs, and Query Store

Find and fix slow queries using execution plans, dynamic management views, Query Store, and Query Performance Insight β€” the DBA's diagnostic toolkit.

Finding the slow queries

β˜• Simple explanation

Think of a traffic control centre.

Execution plans are like GPS route maps β€” they show the path SQL Server chose for your query and where it got stuck in traffic. DMVs are dashboard cameras at every intersection β€” real-time views of what is happening right now. Query Store is the traffic history database β€” it records every query’s performance over time so you can spot regressions. Query Performance Insight is the executive dashboard β€” a visual summary of your biggest bottlenecks.

The DP-800 exam expects you to diagnose performance issues using four tools: execution plans (estimated and actual) to understand query optimiser decisions, DMVs for real-time server state, Query Store for historical performance tracking and plan forcing, and Query Performance Insight (Azure SQL) for visual top-query analysis.

Execution plans

Every query goes through the query optimiser, which generates an execution plan β€” the step-by-step instructions for retrieving data.

-- Show estimated plan (does not execute the query)
SET SHOWPLAN_XML ON;
GO
SELECT * FROM Orders WHERE CustomerId = 42;
GO
SET SHOWPLAN_XML OFF;

-- Show actual plan (executes and shows real row counts)
SET STATISTICS XML ON;
SELECT * FROM Orders WHERE CustomerId = 42;
SET STATISTICS XML OFF;

What to look for in a plan

Red FlagWhat It MeansFix
Table ScanNo useful index β€” reading every rowCreate an appropriate index
Key LookupIndex found the row but needs extra columnsAdd INCLUDE columns to make a covering index
Sort with high costSorting in memory (or spilling to disk)Add an index with the ORDER BY column
Nested Loops on large tablesRow-by-row processingConsider Hash Join or Merge Join (may need statistics update)
Thick arrowsLarge number of rows flowing between operatorsFilter earlier, add WHERE predicates
Yellow warning triangleImplicit conversion, missing stats, memory grant warningFix data type mismatches, update statistics

Dynamic Management Views (DMVs)

DMVs expose real-time server internals. Key DMVs for performance:

-- Top 10 queries by total CPU time
SELECT TOP 10
    qs.total_worker_time / qs.execution_count AS avg_cpu,
    qs.execution_count,
    SUBSTRING(qt.text, qs.statement_start_offset/2 + 1,
        (CASE WHEN qs.statement_end_offset = -1 THEN LEN(qt.text)
         ELSE qs.statement_end_offset/2 END - qs.statement_start_offset/2) + 1) AS query_text
FROM sys.dm_exec_query_stats qs
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) qt
ORDER BY qs.total_worker_time DESC;
DMVWhat It Shows
sys.dm_exec_query_statsAggregated query performance (CPU, reads, duration)
sys.dm_exec_requestsCurrently executing requests (blocking, waits)
sys.dm_exec_sessionsActive sessions and their state
sys.dm_db_index_usage_statsWhich indexes are being used (and which are not)
sys.dm_db_missing_index_detailsIndexes the optimiser wishes it had
sys.dm_os_wait_statsServer-wide wait statistics (what the server spends time waiting for)

Query Store

Query Store captures query plans and performance metrics over time. It is the key tool for detecting plan regressions β€” when a query suddenly gets a worse execution plan.

-- Enable Query Store
ALTER DATABASE [MyDB] SET QUERY_STORE = ON (
    OPERATION_MODE = READ_WRITE,
    MAX_STORAGE_SIZE_MB = 1024,
    DATA_FLUSH_INTERVAL_SECONDS = 900,
    INTERVAL_LENGTH_MINUTES = 60,
    QUERY_CAPTURE_MODE = AUTO
);

Query Store capabilities

  • Track query performance over time (CPU, duration, reads, writes per plan)
  • Detect regressions β€” compare current performance to a baseline
  • Force plans β€” pin a known-good execution plan to a query
  • View plan history β€” see all plans a query has used and when each was active
πŸ’‘ Exam tip: Database configurations that affect performance

The exam may ask you to β€œrecommend database configurations.” Key settings:

  • MAXDOP (max degree of parallelism) β€” controls how many CPUs a query can use
  • Cost threshold for parallelism β€” minimum plan cost before parallelism kicks in
  • Memory grants β€” how much memory queries can request for sorts and hashes
  • Compatibility level β€” newer levels enable better optimiser features (batch mode, adaptive joins)
  • Auto-tuning (Azure SQL) β€” automatically forces better plans and creates missing indexes
  • READ_COMMITTED_SNAPSHOT β€” reduces blocking (covered in the previous module)

Query Performance Insight (Azure SQL)

For Azure SQL Database, Query Performance Insight provides a visual dashboard in the Azure portal:

  • Top queries by CPU, data IO, or log IO
  • Query duration trends over time
  • Recommendation integration with Azure SQL Advisor
Question

What is the difference between an estimated and actual execution plan?

Click or press Enter to reveal answer

Answer

An estimated plan shows the optimiser's predicted path WITHOUT executing the query (fast, no data impact). An actual plan EXECUTES the query and shows real row counts, memory grants, and actual vs estimated differences. Use actual plans for diagnosing performance issues.

Click to flip back

Question

What does Query Store do?

Click or press Enter to reveal answer

Answer

Query Store captures query execution plans and performance metrics over time. It enables: tracking query regressions (when a plan changes for the worse), comparing plan performance, forcing known-good plans, and historical analysis. It is the primary tool for plan regression detection.

Click to flip back

Question

Which DMV shows missing indexes?

Click or press Enter to reveal answer

Answer

sys.dm_db_missing_index_details shows indexes the query optimiser wished it had during query compilation. It includes the table, equality columns, inequality columns, and included columns. Use it alongside sys.dm_db_missing_index_group_stats for impact estimates.

Click to flip back

Knowledge Check

After a weekend deployment, Priya notices that a critical report query at Vault Bank went from 2 seconds to 45 seconds. The query has not changed. What is the most likely cause and best diagnostic tool?

🎬 Video coming soon

Next up: SQL Database Projects: Build and Validate β€” manage your database schema as code with SQL Database Projects.

← Previous

Transaction Isolation and Concurrency

Next β†’

SQL Database Projects: Build and Validate

Guided

I learn, I simplify, I share.

A Guide to Cloud YouTube Feedback

© 2026 Sutheesh. All rights reserved.

Guided is an independent study resource and is not affiliated with, endorsed by, or officially connected to Microsoft. Microsoft, Azure, and related trademarks are property of Microsoft Corporation. Always verify information against Microsoft Learn.