πŸ”’ 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 6 of 7 86%
17 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 ⏱ ~12 min read

Database Maintenance: Indexes, Statistics, and Integrity

Implement index maintenance tasks, statistics updates, and database integrity checks to keep Azure SQL databases healthy and performing well.

Keeping databases healthy

β˜• Simple explanation

Database maintenance is like car servicing.

Index maintenance is like wheel alignment β€” over time, indexes get fragmented (out of order), making reads slower. Reorganise (minor tune-up) or rebuild (major service) to fix them.

Statistics are the GPS maps β€” they tell the optimizer how data is distributed. Outdated stats = bad route choices = slow queries. Update stats regularly.

Integrity checks are the MOT inspection β€” they verify nothing is physically corrupted. Find problems before they cause data loss.

Regular maintenance ensures optimal performance and data integrity. The three pillars: index defragmentation, statistics currency, and consistency verification.

Index maintenance

Fragmentation levels and actions

Fragmentation %ActionT-SQLImpact
Under 5%Noneβ€”Negligible
5% – 30%ReorganiseALTER INDEX ... REORGANIZEOnline, minimal impact
Over 30%RebuildALTER INDEX ... REBUILDCan be online (Enterprise) or offline
-- Check fragmentation levels
SELECT
    OBJECT_NAME(ips.object_id) AS table_name,
    i.name AS index_name,
    ips.avg_fragmentation_in_percent,
    ips.page_count
FROM sys.dm_db_index_physical_stats(DB_ID(), NULL, NULL, NULL, 'LIMITED') ips
JOIN sys.indexes i ON ips.object_id = i.object_id AND ips.index_id = i.index_id
WHERE ips.page_count > 1000  -- skip tiny tables
ORDER BY ips.avg_fragmentation_in_percent DESC;

-- Reorganise (online, minimal lock)
ALTER INDEX IX_Orders_Date ON dbo.Orders REORGANIZE;

-- Rebuild (offline by default, online with Enterprise)
ALTER INDEX IX_Orders_Date ON dbo.Orders REBUILD WITH (ONLINE = ON);

-- Rebuild all indexes on a table
ALTER INDEX ALL ON dbo.Orders REBUILD;

Reorganise vs rebuild

Reorganise vs Rebuild
AspectReorganiseRebuild
When to use5-30% fragmentationOver 30% fragmentation
Online?Always onlineOffline by default (online = Enterprise)
LockingMinimal (row-level)Heavy (table lock if offline)
StatisticsNOT updatedAutomatically updates statistics
ResumableNoYes (RESUMABLE = ON in SQL 2017+)
Space neededMinimalNeeds extra space for new copy
ℹ️ Azure SQL Database and index maintenance

Azure SQL Database handles some index maintenance automatically, but not all:

  • Automatic tuning can create and drop indexes based on workload patterns
  • You should still monitor fragmentation and schedule maintenance for critical indexes
  • All Azure SQL Database tiers support online index rebuild (no Enterprise requirement like on-prem)
  • Use resumable index rebuilds for large indexes β€” if interrupted, resume without starting over

Statistics maintenance

Statistics tell the query optimizer how data is distributed in tables and indexes. Inaccurate statistics lead to bad execution plans.

Auto-update statistics

  • Enabled by default on all platforms
  • Triggers when ~20% of rows change (with modifications to this threshold for large tables)
  • Happens asynchronously by default on Azure SQL Database

Manual statistics updates

-- Update statistics for a specific table
UPDATE STATISTICS dbo.Orders;

-- Update with full scan (most accurate, most expensive)
UPDATE STATISTICS dbo.Orders WITH FULLSCAN;

-- Update a specific statistics object
UPDATE STATISTICS dbo.Orders IX_Orders_Date;

-- Check when statistics were last updated
SELECT
    OBJECT_NAME(s.object_id) AS table_name,
    s.name AS stats_name,
    sp.last_updated,
    sp.rows,
    sp.modification_counter
FROM sys.stats s
CROSS APPLY sys.dm_db_stats_properties(s.object_id, s.stats_id) sp
WHERE sp.modification_counter > 0
ORDER BY sp.modification_counter DESC;

When to update manually

  • After large data loads (bulk import, ETL)
  • Before running critical reports
  • When Query Store shows plan regressions correlating with stale stats
  • For tables with skewed data distribution

Integrity checks (DBCC CHECKDB)

DBCC CHECKDB verifies the physical and logical integrity of every object in the database.

-- Full integrity check
DBCC CHECKDB ('NorthStarERP') WITH NO_INFOMSGS;

-- Check a specific table
DBCC CHECKTABLE ('dbo.Orders') WITH NO_INFOMSGS;

-- Check allocation consistency only (faster)
DBCC CHECKALLOC ('NorthStarERP') WITH NO_INFOMSGS;

-- Check catalog consistency
DBCC CHECKCATALOG ('NorthStarERP') WITH NO_INFOMSGS;

DBCC CHECKDB on Azure SQL

PlatformSupportNotes
SQL DatabaseDBCC CHECKDB runs but Microsoft handles integrity checks automaticallyYou can run it manually for verification
Managed InstanceFull DBCC supportSchedule via SQL Agent jobs
SQL on VMsFull DBCC supportMust schedule yourself (Agent job or maintenance plan)
πŸ’‘ What to do when CHECKDB finds errors

If DBCC CHECKDB reports corruption:

  1. Don’t panic β€” check if the error is on a data page or index page
  2. Index corruption: Rebuild the index (ALTER INDEX ... REBUILD)
  3. Data page corruption: Restore the page from backup (RESTORE DATABASE ... PAGE)
  4. Last resort: DBCC CHECKDB ... WITH REPAIR_ALLOW_DATA_LOSS β€” fixes corruption but may lose data
  5. Always restore from backup if possible β€” repair is the last option

On Azure SQL DB, Microsoft monitors integrity. On MI and VMs, schedule CHECKDB weekly.

Automatic tuning

Azure SQL Database includes automatic tuning capabilities:

FeatureWhat It DoesDefault
Force last good planAutomatically forces a known-good plan when a regression is detectedON
Create indexCreates indexes recommended by the workload analysisOFF
Drop indexDrops unused indexes identified by workload analysisOFF
-- Check automatic tuning status
SELECT name, desired_state_desc, actual_state_desc
FROM sys.database_automatic_tuning_options;

-- Enable automatic index management
ALTER DATABASE CURRENT SET AUTOMATIC_TUNING (
    FORCE_LAST_GOOD_PLAN = ON,
    CREATE_INDEX = ON,
    DROP_INDEX = ON
);
Question

At what fragmentation level should you reorganise vs rebuild an index?

Click or press Enter to reveal answer

Answer

5-30%: Reorganise (online, minimal impact). Over 30%: Rebuild (heavier, but more thorough). Under 5%: Do nothing.

Click to flip back

Question

Does ALTER INDEX REORGANIZE update statistics?

Click or press Enter to reveal answer

Answer

No. Reorganise does NOT update statistics. Rebuild does update statistics automatically. After reorganising, you may need to manually UPDATE STATISTICS.

Click to flip back

Question

What does DBCC CHECKDB verify?

Click or press Enter to reveal answer

Answer

Physical and logical integrity of every object in the database β€” pages, indexes, allocation structures, and catalog metadata. Reports any corruption found.

Click to flip back

Knowledge Check

Kenji notices that a critical query's execution plan changed after a bulk data load, and performance dropped significantly. Statistics show modification_counter is very high. What should he do?

Knowledge Check

Tomas finds that an index on the Orders table has 45% fragmentation and 2 million pages. The table is in constant use by OLTP workloads. What should he do?

🎬 Video coming soon

Next up: Automatic Tuning and Performance Settings β€” configure server settings, Resource Governor, database-scoped configuration, and intelligent query processing.

← Previous

Index and Query Optimization

Next β†’

Automatic Tuning and Performance Settings

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.