How to See Rowcounts and Execution Time for In-Flight Queries in SQL Server
I frequently need to see rowcounts and execution time for queries while they’re running. Maybe I’m troubleshooting a slow query …
Read MoreBy Kendra Little on • 5 min read
It took me more than half hour to figure out how to start an XEvents trace on a read-scale out instance of Azure SQL Managed Instance. It’s hard to monitor read scale-out instances, so tracing is desirable! I started with a simple trace of sql_statement_completed. Hopefully this saves other folks some time.
Read scale-out instances are provided when you use the Business Critical tier for Azure SQL Managed Instance. These use an availability-groups like technology to keep databases fresh in a read-only format.
You can offload queries to this read-only replica with near realtime data. However, the instances are tricky to monitor: most 3rd party monitoring systems have no idea what these are, and they don’t emit performance counters like a ’normal’ instance.
If you have configured a Failover Group and the failover partner is in the Business Critical service tier, that partner will also have read scale-out instances.

I typically like to create both an event file target and a ring buffer target if the trace may run for a while.
There’s a few steps to set up a Managed Instance to work with event file targets. You can reuse this configuration for multiple XEvents traces, if that’s a comfort.
Follow the steps in Create an event session with an event_file target in Azure Storage to do the following in the Azure Portal:
After this, the article instructs you to run a TSQL command against your Managed Instance to store the SAS token in a server-scoped credential.
Where to run this step: The Managed Instance which is the “base” of the read scale-out instance. This might be your primary writable replica, or it might be the failover partner, or it might be both. (It is NOT the read scale-out instance. Connect with ApplicationIntent=ReadWrite.)
If you aren’t sure if this may have been done before, check if a credential has been set up in your Managed Instance with the following query:
USE master;
GO
SELECT
*
FROM sys.credentials AS c;
GO
The credential name will be something like:
https://exampleaccount4xe.blob.core.windows.net/xe-example-container
The identity will be SHARED ACCESS SIGNATURE.
Where to run this step: The Managed Instance which is the “base” of the read scale-out instance. This might be your primary writable replica, or it might be the failover partner, or it might be both. (It is NOT the read scale-out instance. Connect with ApplicationIntent=ReadWrite.)
SQL Server Management Studio (SSMS) only partially supports creating XEvents sessions. You can use the built in wizard to configure the session, but when you go to configure where to write the event file target it will thing the url for the location is an error.
So you need to script out the definition to TSQL, put the URL into the TSQL, and execute it in SQL to create the XEvents trace.
Is this a stack of workarounds in a trench coat? Absolutely.

Your trace now should exist on the Managed Instance where you created it (a primary replica or a failover partner).
If you now connect to your read scale-out instance (ApplicationIntent=READONLY), you should see in Object Explorer that the definition has synced over.
I had to open a second instance of SSMS to get Object Explorer to have connections to both an instance and its read scale-out partner at the same time.
At the time I wrote this, the documentation claimed:
An extended event session on a read-only replica that is based on a session definition from the primary replica can be started and stopped independently of the session on the primary replica.
I didn’t find that to be true. If I attempted to start the XEvents trace on the read scale-out replica at this point, I got the error:
Msg 3906, Level 16, State 2, Line 1
Failed to update database "master" because the database is read-only.
In order to get the trace started on the read scale-out instance, I had to do a little dance:
I put in a PR to update the docs, so hopefully someone verifies this and figures out if it’s the same or different for Azure SQL Database.
If you don’t need the trace to run on the primary replica or failover partner, you can stop it there. But don’t drop it– you need to leave it there as long as you want to run it on the read scale-out instance.
Hopefully nobody comes along and cleans it up.
Is it writing to the targets and picking up data? After all this, I sure hope so.
The good news is that you can now open the results of event-file traces inside SSMS, like a normal XEvents trace. This isa recent improvement which is VERY nice– you used to have to download the files from Azure Storage, which required stopping a trace and other bother. It’s much more convenient to work with trace data in SSMS now for Azure SQL Managed Instance.
Copyright (c) 2025, Catalyze SQL, LLC; all rights reserved. Opinions expressed on this site are solely those of Kendra Little of Catalyze SQL, LLC. Content policy: Short excerpts of blog posts (3 sentences) may be republished, but longer excerpts and artwork cannot be shared without explicit permission.