Book Image

Professional Azure SQL Database Administration - Second Edition

By : Ahmad Osama
Book Image

Professional Azure SQL Database Administration - Second Edition

By: Ahmad Osama

Overview of this book

Despite being the cloud version of SQL Server, Azure SQL Database differs in key ways when it comes to management, maintenance, and administration. This book shows you how to administer Azure SQL Database to fully benefit from its wide range of features and functionalities. Professional Azure SQL Database Administration begins by covering the architecture and explaining the difference between Azure SQL Database and the on-premise SQL Server to help you get comfortable with Azure SQL Database. You’ll perform common tasks such as migrating, backing up and restoring a SQL Server database to an Azure database. As you progress, you’ll understand how you can reduce costs, and manage and scale multiple SQL databases using elastic pools. You’ll also implement a disaster recovery solution using standard and active geo-replication. Whether it is learning different techniques to monitor and tune an Azure SQL Database or improving performance using in-memory technology, this book will enable you to make the most out of Azure SQL database features and functionality for data management solutions. By the end of this book, you’ll be well-versed with key aspects of an Azure SQL Database instance, such as migration, backup restorations, performance optimization, high availability, and disaster recovery.
Table of Contents (11 chapters)

Monitoring an Azure SQL Database Using DMVs

DMVs return diagnostic data that can be used to monitor a database's health and performance.

Monitoring Database Metrics

The metrics available on the Azure portal can also be monitored using the sys.resource_stats DMV. This DMV returns the historical analysis for all the databases in an Azure SQL server. The data is collected and aggregated every 5 minutes and is retained for 14 days.

The following query returns the resource utilization from the last six hours:

Note

You can also copy the queries from the C:\Code\Lesson09\MonitoringDMVs.sql file.

The file location may change depending on where you have unzipped the code files.

-- Execute in master database

-- Get utilization in last 6 hours for the toystore database Declare

@StartTime DATETIME = DATEADD(HH,-3,GetUTCDate()),

@EndTime DATETIME = GetUTCDate() SELECT

database_name, start_time, end_time, avg_cpu_percent, avg_data_io_percent,

avg_log_write_percent, (

SELECT Max(v)

FROM (VALUES (avg_cpu_percent...