All guidesAzure SQL Database

How to keep a history of your Azure SQL read replica's performance

Azure SQL keeps a read replica's own CPU and I/O figures for about an hour. Where they live, how to keep them for weeks, and what to watch.

5 min read

A client says the reports were slow yesterday afternoon. The reports run on the Azure SQL read replica, so you go to look at the replica's CPU, and there is nothing to look at. Azure keeps the replica's own figures for about an hour.

This guide covers what read scale-out gives you, where its performance figures live and how long they last, how to keep them yourself, and what to watch once you have them.

What read scale-out gives you

In the Premium and Business Critical tiers, Azure SQL Database includes a read-only replica at no extra cost. Hyperscale has one once you add a secondary replica. Reports, exports and dashboards can run there and leave the primary free for the application.

A connection goes to the replica when its connection string asks for read-only access. To check where you landed, ask the database:

Server=tcp:<server>.database.windows.net,1433;Database=<database>;ApplicationIntent=ReadOnly;...

SELECT DATABASEPROPERTYEX(DB_NAME(), 'Updateability');
-- READ_ONLY on the replica, READ_WRITE on the primary

The replica is not always up to date. Microsoft puts the usual delay at tens of milliseconds to a few seconds, with no fixed upper limit, and a busy replica falls further behind. So a replica under strain gives slow reports and stale ones.

Why the figures disappear after an hour

Two views hold a database's CPU, data I/O and memory figures, and only one of them sees the replica (Microsoft's monitoring with DMVs and read scale-out pages):

ViewDetailKept forShows the replica
sys.dm_db_resource_stats, run on the replicaEvery 15 secondsAbout an hourYes
sys.resource_stats, in masterEvery 5 minutesAbout 14 daysNo, the primary only

The long history is the primary's. The replica's own figures roll off after about an hour, so anything older than that has to have been copied somewhere first.

Option 1: collect the figures yourself

The fix is a small job that reads the replica's view more often than once an hour and keeps what it reads. It needs a login with the VIEW DATABASE STATE permission, a connection string with ApplicationIntent=ReadOnly, and this query, which picks up every row since the last one it saved:

SELECT end_time, avg_cpu_percent, avg_data_io_percent,
       avg_log_write_percent, avg_memory_usage_percent, max_worker_percent
FROM sys.dm_db_resource_stats
WHERE end_time > @last_end_time
ORDER BY end_time;

An Azure Automation runbook or an Azure Function can run it every 15 minutes or so. Three things catch people out:

  • The replica is read only. The figures have to be written somewhere else: a table in another database, or a storage table.
  • Gaps are permanent. If the job fails for more than an hour, those rows are gone. Watch the job as well as the figures.
  • Someone has to read it. Raw rows are not a chart. Budget for a chart, an alert on sustained high CPU, and a clean-up of old rows.

Option 2: database watcher

Azure SQL database watcher could monitor read replicas and keep their history in Azure Data Explorer. It never left preview: new watchers cannot be created or edited since 9 November 2026, and it retires on 30 April 2027. Microsoft points people to Database Hub in Microsoft Fabric instead. Do not start anything new on it.

What to watch once you have the history

FigureWhat a high value means
CPUReports are competing for the replica. Sustained high CPU is when reports slow down and the replica falls behind
Data I/OQueries are reading a lot from disk, often large scans that an index would avoid
MemoryLess room to cache data, so more reads go to disk
WorkersToo many queries at once. At the limit, new ones are refused

Which to choose

ApproachHistoryWhat you maintainBest for
Query the view by handThe last hourNothingA problem happening right now
Collect it yourselfAs long as you keep itThe job, its storage, a chart and an alertA team with one database to watch
Database watcherEnds on 30 April 2027Nothing new can be set upNobody starting today
A collector built inWeeks, ready to chartA loginMSPs and IT teams watching many databases

How Task Ember does it

Task Ember is a white-label client portal for MSPs and IT teams. Its Read Scale Out Performance product is Option 1, already built:

  • Connects to the replica with read-only intent, using a SQL login you store once, kept in a key vault.
  • Keeps every 15-second row. It collects every 5, 10, 15 or 30 minutes and picks up from the last row it saved, so nothing falls out of the hour in between.
  • Charts CPU, data I/O, log write and memory, from the last hour to the last 14 days.
  • Alerts when the replica's CPU stays high, not on a single busy moment.
  • Says when figures stop arriving, so a gap is noticed while it is still short.

It sits in the client's workspace in your portal, so "were the reports slow yesterday?" has an answer they can see for themselves. See Read Scale Out Performance and the rest of the catalogue at taskember.com/products.

A workspace for every client.

Task Ember is a white-label client portal for MSPs and IT teams. Set up a workspace and switch on the product your clients ask for most.