When I execute the following code in an Azure SQL Database (v12) or SQL Server 2016 instance, I get values in the EstimatedRowsRead column, but not in the EstimatedRows column, and I'm not seeing why. Any ideas?
SET NOCOUNT ON;
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
WITH XMLNAMESPACES(DEFAULT 'http://schemas.microsoft.com/sqlserver/2004/07/showplan')
,PlanHandles AS (
SELECT plan_handle
,total_elapsed_time = SUM(total_elapsed_time)
,execution_count = SUM(execution_count)
FROM sys.dm_exec_query_stats
GROUP BY plan_handle
)
,Plans AS (
SELECT ph.plan_handle, qp.query_plan, ph.total_elapsed_time, ph.execution_count
FROM PlanHandles ph
OUTER APPLY sys.dm_exec_query_plan(ph.plan_handle) qp
)
SELECT p.total_elapsed_time
,p.execution_count
,p.plan_handle
,p.query_plan
,NodeId = s.i.value(N'@NodeId', N'INT')
,EstimatedRowsRead = s.i.value(N'(@EstimatedRowsRead)[1]', N'FLOAT')
,EstimatedRows = s.i.value(N'(@EstimatedRows)[1]', N'FLOAT')
FROM Plans p
CROSS APPLY query_plan.nodes('/ShowPlanXML/BatchSequence/Batch/Statements/*') q(n)
CROSS APPLY n.nodes('.//RelOp[IndexScan and IndexScan/Object[@Schema!="[sys]"]]') s(i)
WHERE s.i.value(N'(@EstimatedRowsRead)[1]', N'FLOAT') > 1.0;