🔒 Guided

Pre-launch preview. Authorised access only.

Incorrect code

Guided by A Guide to Cloud
Explore AB-900 AI-901
Guided DP-300 Domain 3
Domain 3 — Module 3 of 7 43%
14 of 28 overall

DP-300 Study Guide

Domain 1: Plan and Implement Data Platform Resources

  • Choose Your Azure SQL Platform Free
  • Deploy and Configure Azure SQL Free
  • Scale, Performance, and Compression Free
  • Migration Planning: Online vs Offline Free
  • Execute and Troubleshoot Migrations Free

Domain 2: Implement a Secure Environment

  • Entra Authentication for Azure SQL
  • Security Principals, Permissions, and T-SQL
  • Encryption: TDE, Always Encrypted, and VBS Enclaves
  • Network Security: Firewalls, Private Links, and Endpoints
  • Data Classification and Auditing
  • Data Masking, Ledger, and Row-Level Security

Domain 3: Monitor, Configure, and Optimize Database Resources

  • Performance Baselines and Monitoring Tools
  • Database Watcher and Extended Events
  • Query Store: Configure and Monitor
  • Blocking, DMVs, and Execution Plans
  • Index and Query Optimization
  • Database Maintenance: Indexes, Statistics, and Integrity
  • Automatic Tuning and Performance Settings

Domain 4: Configure and Manage Automation of Tasks

  • Automation Landscape: What Runs Where
  • SQL Server Agent Jobs
  • Deploy with ARM, Bicep, PowerShell, and CLI
  • Elastic Jobs and Azure Automation

Domain 5: Plan and Configure an HA/DR Environment

  • HA/DR Strategy: RPO, RTO, and Architecture
  • Backup and Restore: Strategy and Native Tools
  • Point-in-Time Restore, LTR, and Cloud Backup
  • Geo-Replication and Failover Groups
  • Always On: Availability Groups and FCIs
  • Log Shipping and HA/DR Operations

DP-300 Study Guide

Domain 1: Plan and Implement Data Platform Resources

  • Choose Your Azure SQL Platform Free
  • Deploy and Configure Azure SQL Free
  • Scale, Performance, and Compression Free
  • Migration Planning: Online vs Offline Free
  • Execute and Troubleshoot Migrations Free

Domain 2: Implement a Secure Environment

  • Entra Authentication for Azure SQL
  • Security Principals, Permissions, and T-SQL
  • Encryption: TDE, Always Encrypted, and VBS Enclaves
  • Network Security: Firewalls, Private Links, and Endpoints
  • Data Classification and Auditing
  • Data Masking, Ledger, and Row-Level Security

Domain 3: Monitor, Configure, and Optimize Database Resources

  • Performance Baselines and Monitoring Tools
  • Database Watcher and Extended Events
  • Query Store: Configure and Monitor
  • Blocking, DMVs, and Execution Plans
  • Index and Query Optimization
  • Database Maintenance: Indexes, Statistics, and Integrity
  • Automatic Tuning and Performance Settings

Domain 4: Configure and Manage Automation of Tasks

  • Automation Landscape: What Runs Where
  • SQL Server Agent Jobs
  • Deploy with ARM, Bicep, PowerShell, and CLI
  • Elastic Jobs and Azure Automation

Domain 5: Plan and Configure an HA/DR Environment

  • HA/DR Strategy: RPO, RTO, and Architecture
  • Backup and Restore: Strategy and Native Tools
  • Point-in-Time Restore, LTR, and Cloud Backup
  • Geo-Replication and Failover Groups
  • Always On: Availability Groups and FCIs
  • Log Shipping and HA/DR Operations
Domain 3: Monitor, Configure, and Optimize Database Resources Premium ⏱ ~13 min read

Query Store: Configure and Monitor

Configure Query Store to capture query performance history. Use Query Store reports to identify regressions, plan changes, and resource-heavy queries.

Query Store fundamentals

☕ Simple explanation

Query Store is your database’s flight recorder.

Just like a plane’s black box records everything during a flight, Query Store records every query’s execution plan, duration, CPU usage, and I/O — over days, weeks, or months. When a query suddenly gets slow, you can compare “before” and “after” to see exactly what changed.

Best of all, you can force the database to use an older, faster plan — like telling the pilot to go back to the route that worked.

Query Store captures query text, execution plans, and runtime statistics directly inside the database. It persists across server restarts and provides historical comparison capabilities.

Key capabilities: plan regression detection, forced plans, resource consumption analysis, and wait statistics per query. Enabled by default on Azure SQL Database.

Configuring Query Store

Default state by platform

PlatformDefault StateNotes
Azure SQL DatabaseON (Read Write)Enabled automatically on all new databases
Azure SQL Managed InstanceON (Read Write)Enabled automatically
SQL Server on VMsOFFMust be enabled manually

Configuration options

-- Enable Query Store (SQL Server on VMs)
ALTER DATABASE NorthStarERP SET QUERY_STORE = ON;

-- Configure settings
ALTER DATABASE NorthStarERP SET QUERY_STORE (
    OPERATION_MODE = READ_WRITE,
    MAX_STORAGE_SIZE_MB = 1024,
    DATA_FLUSH_INTERVAL_SECONDS = 900,
    INTERVAL_LENGTH_MINUTES = 60,
    CLEANUP_POLICY = (STALE_QUERY_THRESHOLD_DAYS = 30),
    SIZE_BASED_CLEANUP_MODE = AUTO,
    QUERY_CAPTURE_MODE = AUTO,
    MAX_PLANS_PER_QUERY = 200,
    WAIT_STATS_CAPTURE_MODE = ON
);

Key settings explained

SettingWhat It ControlsRecommended
OPERATION_MODEREAD_WRITE (active) or READ_ONLYREAD_WRITE for production
MAX_STORAGE_SIZE_MBMaximum space for Query Store data1-2 GB for most workloads
CLEANUP_POLICYHow long to keep data (STALE_QUERY_THRESHOLD_DAYS)30 days (default)
QUERY_CAPTURE_MODEWhich queries to capture: ALL, AUTO, CUSTOM, NONEAUTO (skips trivial queries)
WAIT_STATS_CAPTURE_MODECapture per-query wait statisticsON
SIZE_BASED_CLEANUP_MODEAuto-purge oldest data when max size reachedAUTO
ℹ️ QUERY_CAPTURE_MODE options
  • ALL: Captures every query. High overhead, useful for thorough analysis.
  • AUTO: Captures queries that exceed resource thresholds (recommended). Skips trivial queries like single lookups.
  • CUSTOM: Fine-tuned with EXECUTION_COUNT and TOTAL_COMPILE_CPU_TIME_MS thresholds.
  • NONE: Query Store is on but not capturing (read-only for existing data).

The exam often tests the difference between ALL and AUTO — AUTO is the recommended production setting.

Monitoring with Query Store

Built-in reports (SSMS)

ReportWhat It ShowsUse For
Regressed QueriesQueries whose performance degraded over timeIdentifying plan regressions
Top Resource Consuming QueriesQueries using the most CPU, duration, I/O, or memoryFinding optimization candidates
Overall Resource ConsumptionDatabase-wide resource trendsCapacity planning
Tracked QueriesPerformance history for a specific queryBefore/after comparison
Queries With Forced PlansQueries where you’ve forced a specific planManaging forced plans
Queries With High VariationQueries with inconsistent performanceIdentifying parameter-sensitive plans

Identifying plan regression

Tomas’s scenario: A sales report that used to run in 2 seconds now takes 45 seconds.

  1. Open Regressed Queries report in SSMS
  2. Find the query — it shows two execution plans
  3. Plan A (old): Index Seek + Nested Loop — fast
  4. Plan B (new): Clustered Index Scan + Hash Join — slow
  5. Compare: Plan B was chosen after a statistics update changed cardinality estimates
  6. Force Plan A — the optimizer will use the fast plan
-- Force a specific plan
EXEC sp_query_store_force_plan @query_id = 42, @plan_id = 7;

-- Unforce a plan
EXEC sp_query_store_unforce_plan @query_id = 42, @plan_id = 7;

-- View forced plans
SELECT query_id, plan_id, force_failure_count
FROM sys.query_store_plan
WHERE is_forced_plan = 1;

Wait statistics per query

Query Store captures wait stats per query — essential for understanding WHY a query is slow:

-- Top queries by total wait time
SELECT TOP 10
    q.query_id,
    qt.query_sql_text,
    ws.wait_category_desc,
    ws.avg_query_wait_time_ms
FROM sys.query_store_query q
JOIN sys.query_store_query_text qt ON q.query_text_id = qt.query_text_id
JOIN sys.query_store_wait_stats ws ON q.query_id = ws.query_id
ORDER BY ws.avg_query_wait_time_ms DESC;

Query Store best practices

PracticeWhy
Keep OPERATION_MODE = READ_WRITEActive collection is the default and recommended
Use AUTO capture modeAvoids overhead from trivial queries
Monitor Query Store sizeIf it fills up, it switches to READ_ONLY automatically
Force plans cautiouslyForced plans may become suboptimal as data changes — review periodically
Don’t disable on Azure SQL DBIt’s enabled by default for a reason — monitoring without it is much harder
Use custom capture for OLTPFine-tune thresholds to skip high-frequency, low-cost queries
Question

What happens when Query Store reaches its maximum storage size?

Click or press Enter to reveal answer

Answer

It automatically switches to READ_ONLY mode — existing data is preserved but new data isn't collected. If SIZE_BASED_CLEANUP_MODE is AUTO, it purges the oldest data first to make room.

Click to flip back

Question

What is plan forcing in Query Store?

Click or press Enter to reveal answer

Answer

You tell the optimizer to always use a specific execution plan for a query. Useful when a plan regression occurs — force the old, faster plan. Use sp_query_store_force_plan to force and sp_query_store_unforce_plan to release.

Click to flip back

Question

Is Query Store enabled by default on Azure SQL Database?

Click or press Enter to reveal answer

Answer

Yes — Query Store is ON (READ_WRITE) by default on all Azure SQL Database and Managed Instance databases. On SQL Server (VMs), it must be enabled manually.

Click to flip back

Knowledge Check

A critical report query suddenly became 20x slower after a statistics update. Tomas finds two plans in Query Store — Plan A (fast, old) and Plan B (slow, new). What should he do first?

Knowledge Check

Priya wants Query Store to capture significant queries but skip trivial single-row lookups that execute thousands of times per second. Which capture mode should she use?

🎬 Video coming soon

Next up: Blocking, DMVs, and Execution Plans — diagnose session blocking, use DMVs for performance analysis, and read execution plans.

← Previous

Database Watcher and Extended Events

Next →

Blocking, DMVs, and Execution Plans

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.