By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE SalesLedger (Id int PRIMARY KEY IDENTITY, Date date NOT NULL, Total decimal(38,18), INDEX IX (Date, Total));
CREATE TABLE Purchases (Id int PRIMARY KEY IDENTITY, Date date NOT NULL, Total decimal(38,18), INDEX IX (Date, Total));
CREATE VIEW ViewMetrics
AS
Select
Date,
'Sale' as Metric,
Total as Value
From SalesLedger
UNION ALL
Select
Date,
'Purchase' as Metric,
Total as Value
From Purchases;
SET STATISTICS XML ON;
Select SUM(Value) as Sales, Date
from ViewMetrics
Group By Date;
SELECT SUM(Sales), Date
FROM (
Select SUM(Value) as Sales, Date
from ViewMetrics
Group By Metric, Date
) t
GROUP BY Date;
Select SUM(Value) as Sales, Date
from ViewMetrics
where Metric = 'Sale'
Group By Date;
Sales | Date |
---|
Microsoft SQL Server 2005 XML Showplan |
---|
<ShowPlanXML xmlns="http://schemas.microsoft.com/sqlserver/2004/07/showplan" Version="1.564" Build="16.0.1000.6"><BatchSequence><Batch><Statements><StmtSimple StatementText="Select SUM(Value) as Sales, Date
from ViewMetrics
Group By Date" StatementId="1" StatementCompId="2" StatementType="SELECT" StatementSqlHandle="0x0900B92A33A2977E29D43335E774CE34EAC30000000000000000000000000000000000000000000000000000" DatabaseContextSettingsId="1" ParentObjectId="0" StatementParameterizationType="0" RetrievedFromCache="true" StatementSubTreeCost="0.0121705" StatementEstRows="1.5" SecurityPolicyApplied="false" StatementOptmLevel="FULL" QueryHash="0x5AFA3E235439405F" QueryPlanHash="0xBCA44B1CD2BFA7D9" StatementOptmEarlyAbortReason="GoodEnoughPlanFound" CardinalityEstimationModelVersion="160"><StatementSetOptions QUOTED_IDENTIFIER="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" NUMERIC_ROUNDABORT="false"></StatementSetOptions><QueryPlan DegreeOfParallelism="0" NonParallelPlanReason="NoParallelPlansInDesktopOrExpressEdition" CachedPlanSize="24" CompileTime="15" CompileCPU="0" CompileMemory="328"><MemoryGrantInfo SerialRequiredMemory="0" SerialDesiredMemory="0" GrantedMemory="0" MaxUsedMemory="0"></MemoryGrantInfo><OptimizerHardwareDependentProperties EstimatedAvailableMemoryGrant="1258238" EstimatedPagesCached="78639" EstimatedAvailableDegreeOfParallelism="1" MaxCompileMemory="1389512"></OptimizerHardwareDependentProperties><TraceFlags IsCompileTime="1"><TraceFlag Value="460" Scope="Global"></TraceFlag><TraceFlag Value="8017" Scope="Global"></TraceFlag></TraceFlags><TraceFlags IsCompileTime="0"><TraceFlag Value="460" Scope="Global"></TraceFlag><TraceFlag Value="8017" Scope="Global"></TraceFlag></TraceFlags><QueryTimeStats ElapsedTime="0" CpuTime="0"></QueryTimeStats><RelOp NodeId="0" PhysicalOp="Compute Scalar" LogicalOp="Compute Scalar" EstimateRows="1.5" EstimateIO="0" EstimateCPU="0" AvgRowSize="27" EstimatedTotalSubtreeCost="0.0121705" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Column="Union1006"></ColumnReference><ColumnReference Column="Expr1009"></ColumnReference></OutputList><ComputeScalar><DefinedValues><DefinedValue><ColumnReference Column="Expr1009"></ColumnReference><ScalarOperator ScalarString="CASE WHEN [Expr1014]=(0) THEN NULL ELSE [Expr1015] END"><IF><Condition><ScalarOperator><Compare CompareOp="EQ"><ScalarOperator><Identifier><ColumnReference Column="Expr1014"></ColumnReference></Identifier></ScalarOperator><ScalarOperator><Const ConstValue="(0)"></Const></ScalarOperator></Compare></ScalarOperator></Condition><Then><ScalarOperator><Const ConstValue="NULL"></Const></ScalarOperator></Then><Else><ScalarOperator><Identifier><ColumnReference Column="Expr1015"></ColumnReference></Identifier></ScalarOperator></Else></IF></ScalarOperator></DefinedValue></DefinedValues><RelOp NodeId="1" PhysicalOp="Stream Aggregate" LogicalOp="Aggregate" EstimateRows="1.5" EstimateIO="0" EstimateCPU="1.95e-06" AvgRowSize="27" EstimatedTotalSubtreeCost="0.0121705" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Column="Union1006"></ColumnReference><ColumnReference Column="Expr1014"></ColumnReference><ColumnReference Column="Expr1015"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="0" Batches="0" ActualElapsedms="0" ActualCPUms="0" ActualEndOfScans="1" ActualExecutions="1" ActualExecutionMode="Row"></RunTimeCountersPerThread></RunTimeInformation><StreamAggregate><DefinedValues><DefinedValue><ColumnReference Column="Expr1014"></ColumnReference><ScalarOperator ScalarString="COUNT_BIG([Union1008])"><Aggregate Distinct="0" AggType="COUNT_BIG"><ScalarOperator><Identifier><ColumnReference Column="Union1008"></ColumnReference></Identifier></ScalarOperator></Aggregate></ScalarOperator></DefinedValue><DefinedValue><ColumnReference Column="Expr1015"></ColumnReference><ScalarOperator ScalarString="SUM([Union1008])"><Aggregate Distinct="0" AggType="SUM"><ScalarOperator><Identifier><ColumnReference Column="Union1008"></ColumnReference></Identifier></ScalarOperator></Aggregate></ScalarOperator></DefinedValue></DefinedValues><GroupBy><ColumnReference Column="Union1006"></ColumnReference></GroupBy><RelOp NodeId="2" PhysicalOp="Merge Join" LogicalOp="Concatenation" EstimateRows="2" EstimateIO="0" EstimateCPU="0.0056023" AvgRowSize="27" EstimatedTotalSubtreeCost="0.0121685" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Column="Union1006"></ColumnReference><ColumnReference Column="Union1008"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="0" Batches="0" ActualElapsedms="0" ActualCPUms="0" ActualScans="0" ActualLogicalReads="0" ActualPhysicalReads="0" ActualReadAheads="0" ActualLobLogicalReads="0" ActualLobPhysicalReads="0" ActualLobReadAheads="0" ActualEndOfScans="1" ActualExecutions="1" ActualExecutionMode="Row"></RunTimeCountersPerThread></RunTimeInformation><Merge><DefinedValues><DefinedValue><ColumnReference Column="Union1006"></ColumnReference><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[SalesLedger]" Column="Date"></ColumnReference><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[Purchases]" Column="Date"></ColumnReference></DefinedValue><DefinedValue><ColumnReference Column="Union1008"></ColumnReference><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[SalesLedger]" Column="Total"></ColumnReference><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[Purchases]" Column="Total"></ColumnReference></DefinedValue></DefinedValues><RelOp NodeId="3" PhysicalOp="Index Scan" LogicalOp="Index Scan" EstimateRows="1" EstimatedRowsRead="1" EstimateIO="0.003125" EstimateCPU="0.0001581" AvgRowSize="27" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="0" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[SalesLedger]" Column="Date"></ColumnReference><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[SalesLedger]" Column="Total"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="0" Batches="0" ActualElapsedms="0" ActualCPUms="0" ActualScans="1" ActualLogicalReads="0" ActualPhysicalReads="0" ActualReadAheads="0" ActualLobLogicalReads="0" ActualLobPhysicalReads="0" ActualLobReadAheads="0" ActualEndOfScans="1" ActualExecutions="1" ActualExecutionMode="Row"></RunTimeCountersPerThread></RunTimeInformation><IndexScan Ordered="1" ScanDirection="FORWARD" ForcedIndex="0" ForceSeek="0" ForceScan="0" NoExpandHint="0" Storage="RowStore"><DefinedValues><DefinedValue><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[SalesLedger]" Column="Date"></ColumnReference></DefinedValue><DefinedValue><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[SalesLedger]" Column="Total"></ColumnReference></DefinedValue></DefinedValues><Object Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[SalesLedger]" Index="[IX]" IndexKind="NonClustered" Storage="RowStore"></Object></IndexScan></RelOp><RelOp NodeId="4" PhysicalOp="Index Scan" LogicalOp="Index Scan" EstimateRows="1" EstimatedRowsRead="1" EstimateIO="0.003125" EstimateCPU="0.0001581" AvgRowSize="27" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="0" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[Purchases]" Column="Date"></ColumnReference><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[Purchases]" Column="Total"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="0" Batches="0" ActualElapsedms="0" ActualCPUms="0" ActualScans="1" ActualLogicalReads="0" ActualPhysicalReads="0" ActualReadAheads="0" ActualLobLogicalReads="0" ActualLobPhysicalReads="0" ActualLobReadAheads="0" ActualEndOfScans="1" ActualExecutions="1" ActualExecutionMode="Row"></RunTimeCountersPerThread></RunTimeInformation><IndexScan Ordered="1" ScanDirection="FORWARD" ForcedIndex="0" ForceSeek="0" ForceScan="0" NoExpandHint="0" Storage="RowStore"><DefinedValues><DefinedValue><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[Purchases]" Column="Date"></ColumnReference></DefinedValue><DefinedValue><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[Purchases]" Column="Total"></ColumnReference></DefinedValue></DefinedValues><Object Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[Purchases]" Index="[IX]" IndexKind="NonClustered" Storage="RowStore"></Object></IndexScan></RelOp></Merge></RelOp></StreamAggregate></RelOp></ComputeScalar></RelOp></QueryPlan></StmtSimple></Statements></Batch></BatchSequence></ShowPlanXML> |
Select SUM(Value) as Sales, Date
from ViewMetrics
Group By Date
SELECT
SELECT
Cached plan size | 24 KB |
---|---|
Estimated Operator Cost | 0 (0%) |
Estimated Subtree Cost | 0.0121705 |
Degree of Parallelism | 0 |
Estimated Number of Rows | 1.5 |
Statement
Select SUM(Value) as Sales, Date
from ViewMetrics
Group By Date
Compute Scalar
Cost: 0%
Compute Scalar
Compute new values from existing values in a row.
Physical Operation | Compute Scalar |
---|---|
Logical Operation | Compute Scalar |
Estimated Execution Mode | Row |
Estimated Operator Cost | 0 (0%) |
Estimated I/O Cost | 0 |
Estimated CPU Cost | 0 |
Estimated Subtree Cost | 0.0121705 |
Estimated Number of Executions | 1 |
Estimated Number of Rows | 1.5 |
Estimated Row Size | 27 B |
Node ID | 0 |
Output List
Union1006
Expr1009
Stream Aggregate
(Aggregate)
Cost: 0%
Stream Aggregate
Compute summary values for groups of rows in a suitably sorted stream.
Physical Operation | Stream Aggregate |
---|---|
Logical Operation | Aggregate |
Actual Execution Mode | Row |
Estimated Execution Mode | Row |
Actual Number of Rows | 0 |
Actual Number of Batches | 0 |
Estimated Operator Cost | 0.000002 (0%) |
Estimated I/O Cost | 0 |
Estimated CPU Cost | 0.000002 |
Estimated Subtree Cost | 0.0121705 |
Estimated Number of Executions | 1 |
Number of Executions | 1 |
Estimated Number of Rows | 1.5 |
Estimated Row Size | 27 B |
Actual Rebinds | 0 |
Actual Rewinds | 0 |
Node ID | 1 |
Output List
Union1006
Expr1014
Expr1015
Merge Join
(Concatenation)
Cost: 46%
Merge Join
Physical Operation | Merge Join |
---|---|
Logical Operation | Concatenation |
Actual Execution Mode | Row |
Estimated Execution Mode | Row |
Actual Number of Rows | 0 |
Actual Number of Batches | 0 |
Estimated Operator Cost | 0.0056023 (46%) |
Estimated I/O Cost | 0 |
Estimated CPU Cost | 0.0056023 |
Estimated Subtree Cost | 0.0121685 |
Estimated Number of Executions | 1 |
Number of Executions | 1 |
Estimated Number of Rows | 2 |
Estimated Row Size | 27 B |
Actual Rebinds | 0 |
Actual Rewinds | 0 |
Node ID | 2 |
Output List
Union1006
Union1008
Index Scan (NonClustered)
[SalesLedger].[IX]
Cost: 27%
Index Scan (NonClustered)
Physical Operation | Index Scan |
---|---|
Logical Operation | Index Scan |
Actual Execution Mode | Row |
Estimated Execution Mode | Row |
Storage | RowStore |
Actual Number of Rows | 0 |
Actual Number of Batches | 0 |
Estimated Operator Cost | 0.0032831 (27%) |
Estimated I/O Cost | 0.003125 |
Estimated CPU Cost | 0.0001581 |
Estimated Subtree Cost | 0.0032831 |
Estimated Number of Executions | 1 |
Number of Executions | 1 |
Estimated Number of Rows to be Read | 1 |
Estimated Number of Rows | 1 |
Estimated Row Size | 27 B |
Actual Rebinds | 0 |
Actual Rewinds | 0 |
Ordered | True |
Node ID | 3 |
Output List
[fiddle_29bdf5153857478eb0161ebbccb5d04d].[dbo].[SalesLedger].Date
[fiddle_29bdf5153857478eb0161ebbccb5d04d].[dbo].[SalesLedger].Total
Object
[fiddle_29bdf5153857478eb0161ebbccb5d04d].[dbo].[SalesLedger].[IX]
Index Scan (NonClustered)
[Purchases].[IX]
Cost: 27%
Index Scan (NonClustered)
Physical Operation | Index Scan |
---|---|
Logical Operation | Index Scan |
Actual Execution Mode | Row |
Estimated Execution Mode | Row |
Storage | RowStore |
Actual Number of Rows | 0 |
Actual Number of Batches | 0 |
Estimated Operator Cost | 0.0032831 (27%) |
Estimated I/O Cost | 0.003125 |
Estimated CPU Cost | 0.0001581 |
Estimated Subtree Cost | 0.0032831 |
Estimated Number of Executions | 1 |
Number of Executions | 1 |
Estimated Number of Rows to be Read | 1 |
Estimated Number of Rows | 1 |
Estimated Row Size | 27 B |
Actual Rebinds | 0 |
Actual Rewinds | 0 |
Ordered | True |
Node ID | 4 |
Output List
[fiddle_29bdf5153857478eb0161ebbccb5d04d].[dbo].[Purchases].Date
[fiddle_29bdf5153857478eb0161ebbccb5d04d].[dbo].[Purchases].Total
Object
[fiddle_29bdf5153857478eb0161ebbccb5d04d].[dbo].[Purchases].[IX]
(No column name) | Date |
---|
Microsoft SQL Server 2005 XML Showplan |
---|
<ShowPlanXML xmlns="http://schemas.microsoft.com/sqlserver/2004/07/showplan" Version="1.564" Build="16.0.1000.6"><BatchSequence><Batch><Statements><StmtSimple StatementText="SELECT SUM(Sales), Date
FROM (
 Select SUM(Value) as Sales, Date
 from ViewMetrics
 Group By Metric, Date
) t
GROUP BY Date" StatementId="2" StatementCompId="3" StatementType="SELECT" StatementSqlHandle="0x090078C607A660E542B7B75061F77CBFC2C10000000000000000000000000000000000000000000000000000" DatabaseContextSettingsId="1" ParentObjectId="0" StatementParameterizationType="0" RetrievedFromCache="true" StatementSubTreeCost="0.0121727" StatementEstRows="1.5" SecurityPolicyApplied="false" StatementOptmLevel="FULL" QueryHash="0xE858FAA683CDBA75" QueryPlanHash="0x9839C6EF432234C6" StatementOptmEarlyAbortReason="GoodEnoughPlanFound" CardinalityEstimationModelVersion="160"><StatementSetOptions QUOTED_IDENTIFIER="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" NUMERIC_ROUNDABORT="false"></StatementSetOptions><QueryPlan DegreeOfParallelism="0" NonParallelPlanReason="NoParallelPlansInDesktopOrExpressEdition" CachedPlanSize="40" CompileTime="0" CompileCPU="0" CompileMemory="632"><MemoryGrantInfo SerialRequiredMemory="0" SerialDesiredMemory="0" GrantedMemory="0" MaxUsedMemory="0"></MemoryGrantInfo><OptimizerHardwareDependentProperties EstimatedAvailableMemoryGrant="1258238" EstimatedPagesCached="78639" EstimatedAvailableDegreeOfParallelism="1" MaxCompileMemory="1389512"></OptimizerHardwareDependentProperties><TraceFlags IsCompileTime="1"><TraceFlag Value="460" Scope="Global"></TraceFlag><TraceFlag Value="8017" Scope="Global"></TraceFlag></TraceFlags><TraceFlags IsCompileTime="0"><TraceFlag Value="460" Scope="Global"></TraceFlag><TraceFlag Value="8017" Scope="Global"></TraceFlag></TraceFlags><QueryTimeStats ElapsedTime="0" CpuTime="0"></QueryTimeStats><RelOp NodeId="0" PhysicalOp="Compute Scalar" LogicalOp="Compute Scalar" EstimateRows="1.5" EstimateIO="0" EstimateCPU="0" AvgRowSize="27" EstimatedTotalSubtreeCost="0.0121727" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Column="Union1006"></ColumnReference><ColumnReference Column="Expr1010"></ColumnReference></OutputList><ComputeScalar><DefinedValues><DefinedValue><ColumnReference Column="Expr1010"></ColumnReference><ScalarOperator ScalarString="CASE WHEN [Expr1031]=(0) THEN NULL ELSE [Expr1032] END"><IF><Condition><ScalarOperator><Compare CompareOp="EQ"><ScalarOperator><Identifier><ColumnReference Column="Expr1031"></ColumnReference></Identifier></ScalarOperator><ScalarOperator><Const ConstValue="(0)"></Const></ScalarOperator></Compare></ScalarOperator></Condition><Then><ScalarOperator><Const ConstValue="NULL"></Const></ScalarOperator></Then><Else><ScalarOperator><Identifier><ColumnReference Column="Expr1032"></ColumnReference></Identifier></ScalarOperator></Else></IF></ScalarOperator></DefinedValue></DefinedValues><RelOp NodeId="1" PhysicalOp="Stream Aggregate" LogicalOp="Aggregate" EstimateRows="1.5" EstimateIO="0" EstimateCPU="1.95e-06" AvgRowSize="27" EstimatedTotalSubtreeCost="0.0121727" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Column="Union1006"></ColumnReference><ColumnReference Column="Expr1031"></ColumnReference><ColumnReference Column="Expr1032"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="0" Batches="0" ActualElapsedms="0" ActualCPUms="0" ActualEndOfScans="1" ActualExecutions="1" ActualExecutionMode="Row"></RunTimeCountersPerThread></RunTimeInformation><StreamAggregate><DefinedValues><DefinedValue><ColumnReference Column="Expr1031"></ColumnReference><ScalarOperator ScalarString="COUNT_BIG([Expr1009])"><Aggregate Distinct="0" AggType="COUNT_BIG"><ScalarOperator><Identifier><ColumnReference Column="Expr1009"></ColumnReference></Identifier></ScalarOperator></Aggregate></ScalarOperator></DefinedValue><DefinedValue><ColumnReference Column="Expr1032"></ColumnReference><ScalarOperator ScalarString="SUM([Expr1009])"><Aggregate Distinct="0" AggType="SUM"><ScalarOperator><Identifier><ColumnReference Column="Expr1009"></ColumnReference></Identifier></ScalarOperator></Aggregate></ScalarOperator></DefinedValue></DefinedValues><GroupBy><ColumnReference Column="Union1006"></ColumnReference></GroupBy><RelOp NodeId="2" PhysicalOp="Merge Join" LogicalOp="Concatenation" EstimateRows="2" EstimateIO="0" EstimateCPU="0.0056023" AvgRowSize="27" EstimatedTotalSubtreeCost="0.0121707" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Column="Union1006"></ColumnReference><ColumnReference Column="Expr1009"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="0" Batches="0" ActualElapsedms="0" ActualCPUms="0" ActualScans="0" ActualLogicalReads="0" ActualPhysicalReads="0" ActualReadAheads="0" ActualLobLogicalReads="0" ActualLobPhysicalReads="0" ActualLobReadAheads="0" ActualEndOfScans="1" ActualExecutions="1" ActualExecutionMode="Row"></RunTimeCountersPerThread></RunTimeInformation><Merge><DefinedValues><DefinedValue><ColumnReference Column="Union1006"></ColumnReference><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[SalesLedger]" Column="Date"></ColumnReference><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[Purchases]" Column="Date"></ColumnReference></DefinedValue><DefinedValue><ColumnReference Column="Expr1009"></ColumnReference><ColumnReference Column="Expr1009"></ColumnReference><ColumnReference Column="Expr1009"></ColumnReference></DefinedValue></DefinedValues><RelOp NodeId="3" PhysicalOp="Compute Scalar" LogicalOp="Compute Scalar" EstimateRows="1" EstimateIO="0" EstimateCPU="0" AvgRowSize="27" EstimatedTotalSubtreeCost="0.0032842" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[SalesLedger]" Column="Date"></ColumnReference><ColumnReference Column="Expr1009"></ColumnReference></OutputList><ComputeScalar><DefinedValues><DefinedValue><ColumnReference Column="Expr1009"></ColumnReference><ScalarOperator ScalarString="CASE WHEN [Expr1027]=(0) THEN NULL ELSE [Expr1028] END"><IF><Condition><ScalarOperator><Compare CompareOp="EQ"><ScalarOperator><Identifier><ColumnReference Column="Expr1027"></ColumnReference></Identifier></ScalarOperator><ScalarOperator><Const ConstValue="(0)"></Const></ScalarOperator></Compare></ScalarOperator></Condition><Then><ScalarOperator><Const ConstValue="NULL"></Const></ScalarOperator></Then><Else><ScalarOperator><Identifier><ColumnReference Column="Expr1028"></ColumnReference></Identifier></ScalarOperator></Else></IF></ScalarOperator></DefinedValue></DefinedValues><RelOp NodeId="4" PhysicalOp="Stream Aggregate" LogicalOp="Aggregate" EstimateRows="1" EstimateIO="0" EstimateCPU="1.1e-06" AvgRowSize="27" EstimatedTotalSubtreeCost="0.0032842" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[SalesLedger]" Column="Date"></ColumnReference><ColumnReference Column="Expr1027"></ColumnReference><ColumnReference Column="Expr1028"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="0" Batches="0" ActualElapsedms="0" ActualCPUms="0" ActualEndOfScans="1" ActualExecutions="1" ActualExecutionMode="Row"></RunTimeCountersPerThread></RunTimeInformation><StreamAggregate><DefinedValues><DefinedValue><ColumnReference Column="Expr1027"></ColumnReference><ScalarOperator ScalarString="COUNT_BIG([fiddle_29bdf5153857478eb0161ebbccb5d04d].[dbo].[SalesLedger].[Total])"><Aggregate Distinct="0" AggType="COUNT_BIG"><ScalarOperator><Identifier><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[SalesLedger]" Column="Total"></ColumnReference></Identifier></ScalarOperator></Aggregate></ScalarOperator></DefinedValue><DefinedValue><ColumnReference Column="Expr1028"></ColumnReference><ScalarOperator ScalarString="SUM([fiddle_29bdf5153857478eb0161ebbccb5d04d].[dbo].[SalesLedger].[Total])"><Aggregate Distinct="0" AggType="SUM"><ScalarOperator><Identifier><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[SalesLedger]" Column="Total"></ColumnReference></Identifier></ScalarOperator></Aggregate></ScalarOperator></DefinedValue></DefinedValues><GroupBy><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[SalesLedger]" Column="Date"></ColumnReference></GroupBy><RelOp NodeId="5" PhysicalOp="Index Scan" LogicalOp="Index Scan" EstimateRows="1" EstimatedRowsRead="1" EstimateIO="0.003125" EstimateCPU="0.0001581" AvgRowSize="27" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="0" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[SalesLedger]" Column="Date"></ColumnReference><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[SalesLedger]" Column="Total"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="0" Batches="0" ActualElapsedms="0" ActualCPUms="0" ActualScans="1" ActualLogicalReads="0" ActualPhysicalReads="0" ActualReadAheads="0" ActualLobLogicalReads="0" ActualLobPhysicalReads="0" ActualLobReadAheads="0" ActualEndOfScans="1" ActualExecutions="1" ActualExecutionMode="Row"></RunTimeCountersPerThread></RunTimeInformation><IndexScan Ordered="1" ScanDirection="FORWARD" ForcedIndex="0" ForceSeek="0" ForceScan="0" NoExpandHint="0" Storage="RowStore"><DefinedValues><DefinedValue><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[SalesLedger]" Column="Date"></ColumnReference></DefinedValue><DefinedValue><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[SalesLedger]" Column="Total"></ColumnReference></DefinedValue></DefinedValues><Object Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[SalesLedger]" Index="[IX]" IndexKind="NonClustered" Storage="RowStore"></Object></IndexScan></RelOp></StreamAggregate></RelOp></ComputeScalar></RelOp><RelOp NodeId="6" PhysicalOp="Compute Scalar" LogicalOp="Compute Scalar" EstimateRows="1" EstimateIO="0" EstimateCPU="0" AvgRowSize="27" EstimatedTotalSubtreeCost="0.0032842" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[Purchases]" Column="Date"></ColumnReference><ColumnReference Column="Expr1009"></ColumnReference></OutputList><ComputeScalar><DefinedValues><DefinedValue><ColumnReference Column="Expr1009"></ColumnReference><ScalarOperator ScalarString="CASE WHEN [Expr1029]=(0) THEN NULL ELSE [Expr1030] END"><IF><Condition><ScalarOperator><Compare CompareOp="EQ"><ScalarOperator><Identifier><ColumnReference Column="Expr1029"></ColumnReference></Identifier></ScalarOperator><ScalarOperator><Const ConstValue="(0)"></Const></ScalarOperator></Compare></ScalarOperator></Condition><Then><ScalarOperator><Const ConstValue="NULL"></Const></ScalarOperator></Then><Else><ScalarOperator><Identifier><ColumnReference Column="Expr1030"></ColumnReference></Identifier></ScalarOperator></Else></IF></ScalarOperator></DefinedValue></DefinedValues><RelOp NodeId="7" PhysicalOp="Stream Aggregate" LogicalOp="Aggregate" EstimateRows="1" EstimateIO="0" EstimateCPU="1.1e-06" AvgRowSize="27" EstimatedTotalSubtreeCost="0.0032842" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[Purchases]" Column="Date"></ColumnReference><ColumnReference Column="Expr1029"></ColumnReference><ColumnReference Column="Expr1030"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="0" Batches="0" ActualElapsedms="0" ActualCPUms="0" ActualEndOfScans="1" ActualExecutions="1" ActualExecutionMode="Row"></RunTimeCountersPerThread></RunTimeInformation><StreamAggregate><DefinedValues><DefinedValue><ColumnReference Column="Expr1029"></ColumnReference><ScalarOperator ScalarString="COUNT_BIG([fiddle_29bdf5153857478eb0161ebbccb5d04d].[dbo].[Purchases].[Total])"><Aggregate Distinct="0" AggType="COUNT_BIG"><ScalarOperator><Identifier><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[Purchases]" Column="Total"></ColumnReference></Identifier></ScalarOperator></Aggregate></ScalarOperator></DefinedValue><DefinedValue><ColumnReference Column="Expr1030"></ColumnReference><ScalarOperator ScalarString="SUM([fiddle_29bdf5153857478eb0161ebbccb5d04d].[dbo].[Purchases].[Total])"><Aggregate Distinct="0" AggType="SUM"><ScalarOperator><Identifier><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[Purchases]" Column="Total"></ColumnReference></Identifier></ScalarOperator></Aggregate></ScalarOperator></DefinedValue></DefinedValues><GroupBy><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[Purchases]" Column="Date"></ColumnReference></GroupBy><RelOp NodeId="8" PhysicalOp="Index Scan" LogicalOp="Index Scan" EstimateRows="1" EstimatedRowsRead="1" EstimateIO="0.003125" EstimateCPU="0.0001581" AvgRowSize="27" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="0" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[Purchases]" Column="Date"></ColumnReference><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[Purchases]" Column="Total"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="0" Batches="0" ActualElapsedms="0" ActualCPUms="0" ActualScans="1" ActualLogicalReads="0" ActualPhysicalReads="0" ActualReadAheads="0" ActualLobLogicalReads="0" ActualLobPhysicalReads="0" ActualLobReadAheads="0" ActualEndOfScans="1" ActualExecutions="1" ActualExecutionMode="Row"></RunTimeCountersPerThread></RunTimeInformation><IndexScan Ordered="1" ScanDirection="FORWARD" ForcedIndex="0" ForceSeek="0" ForceScan="0" NoExpandHint="0" Storage="RowStore"><DefinedValues><DefinedValue><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[Purchases]" Column="Date"></ColumnReference></DefinedValue><DefinedValue><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[Purchases]" Column="Total"></ColumnReference></DefinedValue></DefinedValues><Object Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[Purchases]" Index="[IX]" IndexKind="NonClustered" Storage="RowStore"></Object></IndexScan></RelOp></StreamAggregate></RelOp></ComputeScalar></RelOp></Merge></RelOp></StreamAggregate></RelOp></ComputeScalar></RelOp></QueryPlan></StmtSimple></Statements></Batch></BatchSequence></ShowPlanXML> |
SELECT SUM(Sales), Date
FROM (
Select SUM(Value) as Sales, Date
from ViewMetrics
Group By Metric, Date
) t
GROUP BY Date
SELECT
SELECT
Cached plan size | 40 KB |
---|---|
Estimated Operator Cost | 0 (0%) |
Estimated Subtree Cost | 0.0121727 |
Degree of Parallelism | 0 |
Estimated Number of Rows | 1.5 |
Statement
SELECT SUM(Sales), Date
FROM (
Select SUM(Value) as Sales, Date
from ViewMetrics
Group By Metric, Date
) t
GROUP BY Date
Compute Scalar
Cost: 0%
Compute Scalar
Compute new values from existing values in a row.
Physical Operation | Compute Scalar |
---|---|
Logical Operation | Compute Scalar |
Estimated Execution Mode | Row |
Estimated Operator Cost | 0 (0%) |
Estimated I/O Cost | 0 |
Estimated CPU Cost | 0 |
Estimated Subtree Cost | 0.0121727 |
Estimated Number of Executions | 1 |
Estimated Number of Rows | 1.5 |
Estimated Row Size | 27 B |
Node ID | 0 |
Output List
Union1006
Expr1010
Stream Aggregate
(Aggregate)
Cost: 0%
Stream Aggregate
Compute summary values for groups of rows in a suitably sorted stream.
Physical Operation | Stream Aggregate |
---|---|
Logical Operation | Aggregate |
Actual Execution Mode | Row |
Estimated Execution Mode | Row |
Actual Number of Rows | 0 |
Actual Number of Batches | 0 |
Estimated Operator Cost | 0.000002 (0%) |
Estimated I/O Cost | 0 |
Estimated CPU Cost | 0.000002 |
Estimated Subtree Cost | 0.0121727 |
Estimated Number of Executions | 1 |
Number of Executions | 1 |
Estimated Number of Rows | 1.5 |
Estimated Row Size | 27 B |
Actual Rebinds | 0 |
Actual Rewinds | 0 |
Node ID | 1 |
Output List
Union1006
Expr1031
Expr1032
Merge Join
(Concatenation)
Cost: 46%
Merge Join
Physical Operation | Merge Join |
---|---|
Logical Operation | Concatenation |
Actual Execution Mode | Row |
Estimated Execution Mode | Row |
Actual Number of Rows | 0 |
Actual Number of Batches | 0 |
Estimated Operator Cost | 0.0056023 (46%) |
Estimated I/O Cost | 0 |
Estimated CPU Cost | 0.0056023 |
Estimated Subtree Cost | 0.0121707 |
Estimated Number of Executions | 1 |
Number of Executions | 1 |
Estimated Number of Rows | 2 |
Estimated Row Size | 27 B |
Actual Rebinds | 0 |
Actual Rewinds | 0 |
Node ID | 2 |
Output List
Union1006
Expr1009
Compute Scalar
Cost: 0%
Compute Scalar
Compute new values from existing values in a row.
Physical Operation | Compute Scalar |
---|---|
Logical Operation | Compute Scalar |
Estimated Execution Mode | Row |
Estimated Operator Cost | 0 (0%) |
Estimated I/O Cost | 0 |
Estimated CPU Cost | 0 |
Estimated Subtree Cost | 0.0032842 |
Estimated Number of Executions | 1 |
Estimated Number of Rows | 1 |
Estimated Row Size | 27 B |
Node ID | 3 |
Output List
[fiddle_29bdf5153857478eb0161ebbccb5d04d].[dbo].[SalesLedger].Date
Expr1009
Stream Aggregate
(Aggregate)
Cost: 0%
Stream Aggregate
Compute summary values for groups of rows in a suitably sorted stream.
Physical Operation | Stream Aggregate |
---|---|
Logical Operation | Aggregate |
Actual Execution Mode | Row |
Estimated Execution Mode | Row |
Actual Number of Rows | 0 |
Actual Number of Batches | 0 |
Estimated Operator Cost | 0.0000011 (0%) |
Estimated I/O Cost | 0 |
Estimated CPU Cost | 0.0000011 |
Estimated Subtree Cost | 0.0032842 |
Estimated Number of Executions | 1 |
Number of Executions | 1 |
Estimated Number of Rows | 1 |
Estimated Row Size | 27 B |
Actual Rebinds | 0 |
Actual Rewinds | 0 |
Node ID | 4 |
Output List
[fiddle_29bdf5153857478eb0161ebbccb5d04d].[dbo].[SalesLedger].Date
Expr1027
Expr1028
Index Scan (NonClustered)
[SalesLedger].[IX]
Cost: 27%
Index Scan (NonClustered)
Physical Operation | Index Scan |
---|---|
Logical Operation | Index Scan |
Actual Execution Mode | Row |
Estimated Execution Mode | Row |
Storage | RowStore |
Actual Number of Rows | 0 |
Actual Number of Batches | 0 |
Estimated Operator Cost | 0.0032831 (27%) |
Estimated I/O Cost | 0.003125 |
Estimated CPU Cost | 0.0001581 |
Estimated Subtree Cost | 0.0032831 |
Estimated Number of Executions | 1 |
Number of Executions | 1 |
Estimated Number of Rows to be Read | 1 |
Estimated Number of Rows | 1 |
Estimated Row Size | 27 B |
Actual Rebinds | 0 |
Actual Rewinds | 0 |
Ordered | True |
Node ID | 5 |
Output List
[fiddle_29bdf5153857478eb0161ebbccb5d04d].[dbo].[SalesLedger].Date
[fiddle_29bdf5153857478eb0161ebbccb5d04d].[dbo].[SalesLedger].Total
Object
[fiddle_29bdf5153857478eb0161ebbccb5d04d].[dbo].[SalesLedger].[IX]
Compute Scalar
Cost: 0%
Compute Scalar
Compute new values from existing values in a row.
Physical Operation | Compute Scalar |
---|---|
Logical Operation | Compute Scalar |
Estimated Execution Mode | Row |
Estimated Operator Cost | 0 (0%) |
Estimated I/O Cost | 0 |
Estimated CPU Cost | 0 |
Estimated Subtree Cost | 0.0032842 |
Estimated Number of Executions | 1 |
Estimated Number of Rows | 1 |
Estimated Row Size | 27 B |
Node ID | 6 |
Output List
[fiddle_29bdf5153857478eb0161ebbccb5d04d].[dbo].[Purchases].Date
Expr1009
Stream Aggregate
(Aggregate)
Cost: 0%
Stream Aggregate
Compute summary values for groups of rows in a suitably sorted stream.
Physical Operation | Stream Aggregate |
---|---|
Logical Operation | Aggregate |
Actual Execution Mode | Row |
Estimated Execution Mode | Row |
Actual Number of Rows | 0 |
Actual Number of Batches | 0 |
Estimated Operator Cost | 0.0000011 (0%) |
Estimated I/O Cost | 0 |
Estimated CPU Cost | 0.0000011 |
Estimated Subtree Cost | 0.0032842 |
Estimated Number of Executions | 1 |
Number of Executions | 1 |
Estimated Number of Rows | 1 |
Estimated Row Size | 27 B |
Actual Rebinds | 0 |
Actual Rewinds | 0 |
Node ID | 7 |
Output List
[fiddle_29bdf5153857478eb0161ebbccb5d04d].[dbo].[Purchases].Date
Expr1029
Expr1030
Index Scan (NonClustered)
[Purchases].[IX]
Cost: 27%
Index Scan (NonClustered)
Physical Operation | Index Scan |
---|---|
Logical Operation | Index Scan |
Actual Execution Mode | Row |
Estimated Execution Mode | Row |
Storage | RowStore |
Actual Number of Rows | 0 |
Actual Number of Batches | 0 |
Estimated Operator Cost | 0.0032831 (27%) |
Estimated I/O Cost | 0.003125 |
Estimated CPU Cost | 0.0001581 |
Estimated Subtree Cost | 0.0032831 |
Estimated Number of Executions | 1 |
Number of Executions | 1 |
Estimated Number of Rows to be Read | 1 |
Estimated Number of Rows | 1 |
Estimated Row Size | 27 B |
Actual Rebinds | 0 |
Actual Rewinds | 0 |
Ordered | True |
Node ID | 8 |
Output List
[fiddle_29bdf5153857478eb0161ebbccb5d04d].[dbo].[Purchases].Date
[fiddle_29bdf5153857478eb0161ebbccb5d04d].[dbo].[Purchases].Total
Object
[fiddle_29bdf5153857478eb0161ebbccb5d04d].[dbo].[Purchases].[IX]
Sales | Date |
---|
Microsoft SQL Server 2005 XML Showplan |
---|
<ShowPlanXML xmlns="http://schemas.microsoft.com/sqlserver/2004/07/showplan" Version="1.564" Build="16.0.1000.6"><BatchSequence><Batch><Statements><StmtSimple StatementText="Select SUM(Value) as Sales, Date
from ViewMetrics
where Metric = 'Sale'
Group By Date" StatementId="3" StatementCompId="4" StatementType="SELECT" StatementSqlHandle="0x09002F1D36AF05459FF0EEF614C9B38E1ADB0000000000000000000000000000000000000000000000000000" DatabaseContextSettingsId="1" ParentObjectId="0" StatementParameterizationType="0" RetrievedFromCache="true" StatementSubTreeCost="0.00328478" StatementEstRows="1" SecurityPolicyApplied="false" StatementOptmLevel="FULL" QueryHash="0x50D3B004014848ED" QueryPlanHash="0x9FFD8B01AC91CB4D" StatementOptmEarlyAbortReason="GoodEnoughPlanFound" CardinalityEstimationModelVersion="160"><StatementSetOptions QUOTED_IDENTIFIER="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" NUMERIC_ROUNDABORT="false"></StatementSetOptions><QueryPlan DegreeOfParallelism="0" NonParallelPlanReason="NoParallelPlansInDesktopOrExpressEdition" CachedPlanSize="24" CompileTime="0" CompileCPU="0" CompileMemory="328"><MemoryGrantInfo SerialRequiredMemory="0" SerialDesiredMemory="0" GrantedMemory="0" MaxUsedMemory="0"></MemoryGrantInfo><OptimizerHardwareDependentProperties EstimatedAvailableMemoryGrant="1258238" EstimatedPagesCached="78639" EstimatedAvailableDegreeOfParallelism="1" MaxCompileMemory="1389512"></OptimizerHardwareDependentProperties><TraceFlags IsCompileTime="1"><TraceFlag Value="460" Scope="Global"></TraceFlag><TraceFlag Value="8017" Scope="Global"></TraceFlag></TraceFlags><TraceFlags IsCompileTime="0"><TraceFlag Value="460" Scope="Global"></TraceFlag><TraceFlag Value="8017" Scope="Global"></TraceFlag></TraceFlags><QueryTimeStats ElapsedTime="0" CpuTime="0"></QueryTimeStats><RelOp NodeId="0" PhysicalOp="Compute Scalar" LogicalOp="Compute Scalar" EstimateRows="1" EstimateIO="0" EstimateCPU="0" AvgRowSize="27" EstimatedTotalSubtreeCost="0.00328478" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Column="Union1006"></ColumnReference><ColumnReference Column="Expr1009"></ColumnReference></OutputList><ComputeScalar><DefinedValues><DefinedValue><ColumnReference Column="Expr1009"></ColumnReference><ScalarOperator ScalarString="CASE WHEN [Expr1014]=(0) THEN NULL ELSE [Expr1015] END"><IF><Condition><ScalarOperator><Compare CompareOp="EQ"><ScalarOperator><Identifier><ColumnReference Column="Expr1014"></ColumnReference></Identifier></ScalarOperator><ScalarOperator><Const ConstValue="(0)"></Const></ScalarOperator></Compare></ScalarOperator></Condition><Then><ScalarOperator><Const ConstValue="NULL"></Const></ScalarOperator></Then><Else><ScalarOperator><Identifier><ColumnReference Column="Expr1015"></ColumnReference></Identifier></ScalarOperator></Else></IF></ScalarOperator></DefinedValue></DefinedValues><RelOp NodeId="1" PhysicalOp="Stream Aggregate" LogicalOp="Aggregate" EstimateRows="1" EstimateIO="0" EstimateCPU="1.1e-06" AvgRowSize="27" EstimatedTotalSubtreeCost="0.00328478" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Column="Union1006"></ColumnReference><ColumnReference Column="Expr1014"></ColumnReference><ColumnReference Column="Expr1015"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="0" Batches="0" ActualElapsedms="0" ActualCPUms="0" ActualEndOfScans="1" ActualExecutions="1" ActualExecutionMode="Row"></RunTimeCountersPerThread></RunTimeInformation><StreamAggregate><DefinedValues><DefinedValue><ColumnReference Column="Expr1014"></ColumnReference><ScalarOperator ScalarString="COUNT_BIG([fiddle_29bdf5153857478eb0161ebbccb5d04d].[dbo].[SalesLedger].[Total])"><Aggregate Distinct="0" AggType="COUNT_BIG"><ScalarOperator><Identifier><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[SalesLedger]" Column="Total"></ColumnReference></Identifier></ScalarOperator></Aggregate></ScalarOperator></DefinedValue><DefinedValue><ColumnReference Column="Expr1015"></ColumnReference><ScalarOperator ScalarString="SUM([fiddle_29bdf5153857478eb0161ebbccb5d04d].[dbo].[SalesLedger].[Total])"><Aggregate Distinct="0" AggType="SUM"><ScalarOperator><Identifier><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[SalesLedger]" Column="Total"></ColumnReference></Identifier></ScalarOperator></Aggregate></ScalarOperator></DefinedValue></DefinedValues><GroupBy><ColumnReference Column="Union1006"></ColumnReference></GroupBy><RelOp NodeId="2" PhysicalOp="Filter" LogicalOp="Filter" EstimateRows="1" EstimateIO="0" EstimateCPU="4.8e-07" AvgRowSize="30" EstimatedTotalSubtreeCost="0.00328368" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[SalesLedger]" Column="Date"></ColumnReference><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[SalesLedger]" Column="Total"></ColumnReference><ColumnReference Column="Union1006"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="0" Batches="0" ActualElapsedms="0" ActualCPUms="0" ActualRebinds="1" ActualRewinds="0" ActualEndOfScans="1" ActualExecutions="1" ActualExecutionMode="Row"></RunTimeCountersPerThread></RunTimeInformation><Filter StartupExpression="1"><RelOp NodeId="3" PhysicalOp="Compute Scalar" LogicalOp="Compute Scalar" EstimateRows="1" EstimateIO="0" EstimateCPU="1e-07" AvgRowSize="30" EstimatedTotalSubtreeCost="0.0032832" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[SalesLedger]" Column="Date"></ColumnReference><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[SalesLedger]" Column="Total"></ColumnReference><ColumnReference Column="Union1006"></ColumnReference></OutputList><ComputeScalar><DefinedValues><DefinedValue><ColumnReference Column="Union1006"></ColumnReference><ScalarOperator ScalarString="[fiddle_29bdf5153857478eb0161ebbccb5d04d].[dbo].[SalesLedger].[Date]"><Identifier><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[SalesLedger]" Column="Date"></ColumnReference></Identifier></ScalarOperator></DefinedValue></DefinedValues><RelOp NodeId="4" PhysicalOp="Index Scan" LogicalOp="Index Scan" EstimateRows="1" EstimatedRowsRead="1" EstimateIO="0.003125" EstimateCPU="0.0001581" AvgRowSize="27" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="0" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[SalesLedger]" Column="Date"></ColumnReference><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[SalesLedger]" Column="Total"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="0" Batches="0" ActualElapsedms="0" ActualCPUms="0" ActualScans="1" ActualLogicalReads="0" ActualPhysicalReads="0" ActualReadAheads="0" ActualLobLogicalReads="0" ActualLobPhysicalReads="0" ActualLobReadAheads="0" ActualEndOfScans="1" ActualExecutions="1" ActualExecutionMode="Row"></RunTimeCountersPerThread></RunTimeInformation><IndexScan Ordered="1" ScanDirection="FORWARD" ForcedIndex="0" ForceSeek="0" ForceScan="0" NoExpandHint="0" Storage="RowStore"><DefinedValues><DefinedValue><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[SalesLedger]" Column="Date"></ColumnReference></DefinedValue><DefinedValue><ColumnReference Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[SalesLedger]" Column="Total"></ColumnReference></DefinedValue></DefinedValues><Object Database="[fiddle_29bdf5153857478eb0161ebbccb5d04d]" Schema="[dbo]" Table="[SalesLedger]" Index="[IX]" IndexKind="NonClustered" Storage="RowStore"></Object></IndexScan></RelOp></ComputeScalar></RelOp><Predicate><ScalarOperator ScalarString="'Sale'='Sale'"><Compare CompareOp="EQ"><ScalarOperator><Const ConstValue="'Sale'"></Const></ScalarOperator><ScalarOperator><Const ConstValue="'Sale'"></Const></ScalarOperator></Compare></ScalarOperator></Predicate></Filter></RelOp></StreamAggregate></RelOp></ComputeScalar></RelOp></QueryPlan></StmtSimple></Statements></Batch></BatchSequence></ShowPlanXML> |
Select SUM(Value) as Sales, Date
from ViewMetrics
where Metric = 'Sale'
Group By Date
SELECT
SELECT
Cached plan size | 24 KB |
---|---|
Estimated Operator Cost | 0 (0%) |
Estimated Subtree Cost | 0.0032848 |
Degree of Parallelism | 0 |
Estimated Number of Rows | 1 |
Statement
Select SUM(Value) as Sales, Date
from ViewMetrics
where Metric = 'Sale'
Group By Date
Compute Scalar
Cost: 0%
Compute Scalar
Compute new values from existing values in a row.
Physical Operation | Compute Scalar |
---|---|
Logical Operation | Compute Scalar |
Estimated Execution Mode | Row |
Estimated Operator Cost | 0 (0%) |
Estimated I/O Cost | 0 |
Estimated CPU Cost | 0 |
Estimated Subtree Cost | 0.0032848 |
Estimated Number of Executions | 1 |
Estimated Number of Rows | 1 |
Estimated Row Size | 27 B |
Node ID | 0 |
Output List
Union1006
Expr1009
Stream Aggregate
(Aggregate)
Cost: 0%
Stream Aggregate
Compute summary values for groups of rows in a suitably sorted stream.
Physical Operation | Stream Aggregate |
---|---|
Logical Operation | Aggregate |
Actual Execution Mode | Row |
Estimated Execution Mode | Row |
Actual Number of Rows | 0 |
Actual Number of Batches | 0 |
Estimated Operator Cost | 0.0000011 (0%) |
Estimated I/O Cost | 0 |
Estimated CPU Cost | 0.0000011 |
Estimated Subtree Cost | 0.0032848 |
Estimated Number of Executions | 1 |
Number of Executions | 1 |
Estimated Number of Rows | 1 |
Estimated Row Size | 27 B |
Actual Rebinds | 0 |
Actual Rewinds | 0 |
Node ID | 1 |
Output List
Union1006
Expr1014
Expr1015
Filter
Cost: 0%
Filter
Physical Operation | Filter |
---|---|
Logical Operation | Filter |
Actual Execution Mode | Row |
Estimated Execution Mode | Row |
Actual Number of Rows | 0 |
Actual Number of Batches | 0 |
Estimated Operator Cost | 0.0000005 (0%) |
Estimated I/O Cost | 0 |
Estimated CPU Cost | 0.0000005 |
Estimated Subtree Cost | 0.0032837 |
Estimated Number of Executions | 1 |
Number of Executions | 1 |
Estimated Number of Rows | 1 |
Estimated Row Size | 30 B |
Actual Rebinds | 1 |
Actual Rewinds | 0 |
Node ID | 2 |
Output List
[fiddle_29bdf5153857478eb0161ebbccb5d04d].[dbo].[SalesLedger].Date
[fiddle_29bdf5153857478eb0161ebbccb5d04d].[dbo].[SalesLedger].Total
Union1006
Predicate
'Sale'='Sale'
Compute Scalar
Cost: 0%
Compute Scalar
Compute new values from existing values in a row.
Physical Operation | Compute Scalar |
---|---|
Logical Operation | Compute Scalar |
Estimated Execution Mode | Row |
Estimated Operator Cost | 0.0000001 (0%) |
Estimated I/O Cost | 0 |
Estimated CPU Cost | 0.0000001 |
Estimated Subtree Cost | 0.0032832 |
Estimated Number of Executions | 1 |
Estimated Number of Rows | 1 |
Estimated Row Size | 30 B |
Node ID | 3 |
Output List
[fiddle_29bdf5153857478eb0161ebbccb5d04d].[dbo].[SalesLedger].Date
[fiddle_29bdf5153857478eb0161ebbccb5d04d].[dbo].[SalesLedger].Total
Union1006
Index Scan (NonClustered)
[SalesLedger].[IX]
Cost: 100%
Index Scan (NonClustered)
Physical Operation | Index Scan |
---|---|
Logical Operation | Index Scan |
Actual Execution Mode | Row |
Estimated Execution Mode | Row |
Storage | RowStore |
Actual Number of Rows | 0 |
Actual Number of Batches | 0 |
Estimated Operator Cost | 0.0032831 (100%) |
Estimated I/O Cost | 0.003125 |
Estimated CPU Cost | 0.0001581 |
Estimated Subtree Cost | 0.0032831 |
Estimated Number of Executions | 1 |
Number of Executions | 1 |
Estimated Number of Rows to be Read | 1 |
Estimated Number of Rows | 1 |
Estimated Row Size | 27 B |
Actual Rebinds | 0 |
Actual Rewinds | 0 |
Ordered | True |
Node ID | 4 |
Output List
[fiddle_29bdf5153857478eb0161ebbccb5d04d].[dbo].[SalesLedger].Date
[fiddle_29bdf5153857478eb0161ebbccb5d04d].[dbo].[SalesLedger].Total
Object
[fiddle_29bdf5153857478eb0161ebbccb5d04d].[dbo].[SalesLedger].[IX]