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));
INSERT SalesLedger (Date, Total)
SELECT GETDATE(), number
FROM master..spt_values;
INSERT Purchases (Date, Total)
SELECT GETDATE(), number
FROM master..spt_values;
5148 rows affected
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 |
---|---|
9211907894.000000000000000000 | 2023-08-28 |
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.0459423" StatementEstRows="1" SecurityPolicyApplied="false" StatementOptmLevel="FULL" QueryHash="0x5AFA3E235439405F" QueryPlanHash="0x0970F7ED64ED198C" 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" MemoryGrant="1024" NonParallelPlanReason="NoParallelPlansInDesktopOrExpressEdition" CachedPlanSize="40" CompileTime="0" CompileCPU="0" CompileMemory="352"><MemoryGrantInfo SerialRequiredMemory="512" SerialDesiredMemory="544" RequiredMemory="512" DesiredMemory="544" RequestedMemory="1024" GrantWaitTime="0" MaxQueryMemory="873344" GrantedMemory="1024" MaxUsedMemory="16"></MemoryGrantInfo><OptimizerHardwareDependentProperties EstimatedAvailableMemoryGrant="1258238" EstimatedPagesCached="78639" EstimatedAvailableDegreeOfParallelism="1" MaxCompileMemory="1409224"></OptimizerHardwareDependentProperties><OptimizerStatsUsage><StatisticsInfo LastUpdate="2023-08-28T01:46:15.86" ModificationCount="0" SamplingPercent="100" Statistics="[IX]" Table="[Purchases]" Schema="[dbo]" Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]"></StatisticsInfo><StatisticsInfo LastUpdate="2023-08-28T01:46:15.86" ModificationCount="0" SamplingPercent="100" Statistics="[IX]" Table="[SalesLedger]" Schema="[dbo]" Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]"></StatisticsInfo></OptimizerStatsUsage><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="1" PhysicalOp="Compute Scalar" LogicalOp="Compute Scalar" EstimateRows="1" EstimateIO="0" EstimateCPU="1e-07" AvgRowSize="27" EstimatedTotalSubtreeCost="0.0459423" 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 [globalagg1011]=(0) THEN NULL ELSE [globalagg1013] END"><IF><Condition><ScalarOperator><Compare CompareOp="EQ"><ScalarOperator><Identifier><ColumnReference Column="globalagg1011"></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="globalagg1013"></ColumnReference></Identifier></ScalarOperator></Else></IF></ScalarOperator></DefinedValue></DefinedValues><RelOp NodeId="2" PhysicalOp="Stream Aggregate" LogicalOp="Aggregate" EstimateRows="1" EstimateIO="0" EstimateCPU="1.7e-06" AvgRowSize="35" EstimatedTotalSubtreeCost="0.0459422" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Column="Union1006"></ColumnReference><ColumnReference Column="globalagg1011"></ColumnReference><ColumnReference Column="globalagg1013"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="1" Batches="0" ActualElapsedms="0" ActualCPUms="0" ActualEndOfScans="1" ActualExecutions="1" ActualExecutionMode="Row"></RunTimeCountersPerThread></RunTimeInformation><StreamAggregate><DefinedValues><DefinedValue><ColumnReference Column="globalagg1011"></ColumnReference><ScalarOperator ScalarString="SUM([partialagg1010])"><Aggregate Distinct="0" AggType="SUM"><ScalarOperator><Identifier><ColumnReference Column="partialagg1010"></ColumnReference></Identifier></ScalarOperator></Aggregate></ScalarOperator></DefinedValue><DefinedValue><ColumnReference Column="globalagg1013"></ColumnReference><ScalarOperator ScalarString="SUM([partialagg1012])"><Aggregate Distinct="0" AggType="SUM"><ScalarOperator><Identifier><ColumnReference Column="partialagg1012"></ColumnReference></Identifier></ScalarOperator></Aggregate></ScalarOperator></DefinedValue></DefinedValues><GroupBy><ColumnReference Column="Union1006"></ColumnReference></GroupBy><RelOp NodeId="3" PhysicalOp="Sort" LogicalOp="Sort" EstimateRows="2" EstimateIO="0.0112613" EstimateCPU="0.000103155" AvgRowSize="35" EstimatedTotalSubtreeCost="0.0459405" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Column="Union1006"></ColumnReference><ColumnReference Column="partialagg1010"></ColumnReference><ColumnReference Column="partialagg1012"></ColumnReference></OutputList><MemoryFractions Input="1" Output="1"></MemoryFractions><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="2" Batches="0" ActualElapsedms="0" ActualCPUms="0" ActualScans="0" ActualLogicalReads="0" ActualPhysicalReads="0" ActualReadAheads="0" ActualLobLogicalReads="0" ActualLobPhysicalReads="0" ActualLobReadAheads="0" ActualRebinds="1" ActualRewinds="0" ActualEndOfScans="1" ActualExecutions="1" InputMemoryGrant="1024" OutputMemoryGrant="640" UsedMemoryGrant="16" ActualExecutionMode="Row"></RunTimeCountersPerThread></RunTimeInformation><Sort Distinct="0"><OrderBy><OrderByColumn Ascending="1"><ColumnReference Column="Union1006"></ColumnReference></OrderByColumn></OrderBy><RelOp NodeId="4" PhysicalOp="Concatenation" LogicalOp="Concatenation" EstimateRows="2" EstimateIO="0" EstimateCPU="2e-07" AvgRowSize="35" EstimatedTotalSubtreeCost="0.0345761" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Column="Union1006"></ColumnReference><ColumnReference Column="partialagg1010"></ColumnReference><ColumnReference Column="partialagg1012"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="2" Batches="0" ActualElapsedms="0" ActualCPUms="0" ActualEndOfScans="1" ActualExecutions="1" ActualExecutionMode="Row"></RunTimeCountersPerThread></RunTimeInformation><Concat><DefinedValues><DefinedValue><ColumnReference Column="partialagg1010"></ColumnReference><ColumnReference Column="partialagg1010"></ColumnReference><ColumnReference Column="partialagg1010"></ColumnReference></DefinedValue><DefinedValue><ColumnReference Column="partialagg1012"></ColumnReference><ColumnReference Column="partialagg1012"></ColumnReference><ColumnReference Column="partialagg1012"></ColumnReference></DefinedValue><DefinedValue><ColumnReference Column="Union1006"></ColumnReference><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[SalesLedger]" Column="Date"></ColumnReference><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[Purchases]" Column="Date"></ColumnReference></DefinedValue></DefinedValues><RelOp NodeId="5" PhysicalOp="Stream Aggregate" LogicalOp="Aggregate" EstimateRows="1" EstimateIO="0" EstimateCPU="0.0015449" AvgRowSize="35" EstimatedTotalSubtreeCost="0.0172879" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[SalesLedger]" Column="Date"></ColumnReference><ColumnReference Column="partialagg1010"></ColumnReference><ColumnReference Column="partialagg1012"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="1" Batches="0" ActualElapsedms="0" ActualCPUms="0" ActualEndOfScans="1" ActualExecutions="1" ActualExecutionMode="Row"></RunTimeCountersPerThread></RunTimeInformation><StreamAggregate><DefinedValues><DefinedValue><ColumnReference Column="partialagg1010"></ColumnReference><ScalarOperator ScalarString="COUNT_BIG([fiddle_ec3af89e67f24d15bbb3da76c5b91a2a].[dbo].[SalesLedger].[Total])"><Aggregate Distinct="0" AggType="COUNT_BIG"><ScalarOperator><Identifier><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[SalesLedger]" Column="Total"></ColumnReference></Identifier></ScalarOperator></Aggregate></ScalarOperator></DefinedValue><DefinedValue><ColumnReference Column="partialagg1012"></ColumnReference><ScalarOperator ScalarString="SUM([fiddle_ec3af89e67f24d15bbb3da76c5b91a2a].[dbo].[SalesLedger].[Total])"><Aggregate Distinct="0" AggType="SUM"><ScalarOperator><Identifier><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[SalesLedger]" Column="Total"></ColumnReference></Identifier></ScalarOperator></Aggregate></ScalarOperator></DefinedValue></DefinedValues><GroupBy><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[SalesLedger]" Column="Date"></ColumnReference></GroupBy><RelOp NodeId="6" PhysicalOp="Index Scan" LogicalOp="Index Scan" EstimateRows="2574" EstimatedRowsRead="2574" EstimateIO="0.0127546" EstimateCPU="0.0029884" AvgRowSize="27" EstimatedTotalSubtreeCost="0.015743" TableCardinality="2574" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[SalesLedger]" Column="Date"></ColumnReference><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[SalesLedger]" Column="Total"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="2574" Batches="0" ActualElapsedms="0" ActualCPUms="0" ActualScans="1" ActualLogicalReads="16" ActualPhysicalReads="0" ActualReadAheads="0" ActualLobLogicalReads="0" ActualLobPhysicalReads="0" ActualLobReadAheads="0" ActualRowsRead="2574" 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_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[SalesLedger]" Column="Date"></ColumnReference></DefinedValue><DefinedValue><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[SalesLedger]" Column="Total"></ColumnReference></DefinedValue></DefinedValues><Object Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[SalesLedger]" Index="[IX]" IndexKind="NonClustered" Storage="RowStore"></Object></IndexScan></RelOp></StreamAggregate></RelOp><RelOp NodeId="7" PhysicalOp="Stream Aggregate" LogicalOp="Aggregate" EstimateRows="1" EstimateIO="0" EstimateCPU="0.0015449" AvgRowSize="35" EstimatedTotalSubtreeCost="0.0172879" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[Purchases]" Column="Date"></ColumnReference><ColumnReference Column="partialagg1010"></ColumnReference><ColumnReference Column="partialagg1012"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="1" Batches="0" ActualElapsedms="0" ActualCPUms="0" ActualEndOfScans="1" ActualExecutions="1" ActualExecutionMode="Row"></RunTimeCountersPerThread></RunTimeInformation><StreamAggregate><DefinedValues><DefinedValue><ColumnReference Column="partialagg1010"></ColumnReference><ScalarOperator ScalarString="COUNT_BIG([fiddle_ec3af89e67f24d15bbb3da76c5b91a2a].[dbo].[Purchases].[Total])"><Aggregate Distinct="0" AggType="COUNT_BIG"><ScalarOperator><Identifier><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[Purchases]" Column="Total"></ColumnReference></Identifier></ScalarOperator></Aggregate></ScalarOperator></DefinedValue><DefinedValue><ColumnReference Column="partialagg1012"></ColumnReference><ScalarOperator ScalarString="SUM([fiddle_ec3af89e67f24d15bbb3da76c5b91a2a].[dbo].[Purchases].[Total])"><Aggregate Distinct="0" AggType="SUM"><ScalarOperator><Identifier><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[Purchases]" Column="Total"></ColumnReference></Identifier></ScalarOperator></Aggregate></ScalarOperator></DefinedValue></DefinedValues><GroupBy><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[Purchases]" Column="Date"></ColumnReference></GroupBy><RelOp NodeId="8" PhysicalOp="Index Scan" LogicalOp="Index Scan" EstimateRows="2574" EstimatedRowsRead="2574" EstimateIO="0.0127546" EstimateCPU="0.0029884" AvgRowSize="27" EstimatedTotalSubtreeCost="0.015743" TableCardinality="2574" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[Purchases]" Column="Date"></ColumnReference><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[Purchases]" Column="Total"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="2574" Batches="0" ActualElapsedms="0" ActualCPUms="0" ActualScans="1" ActualLogicalReads="16" ActualPhysicalReads="0" ActualReadAheads="0" ActualLobLogicalReads="0" ActualLobPhysicalReads="0" ActualLobReadAheads="0" ActualRowsRead="2574" 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_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[Purchases]" Column="Date"></ColumnReference></DefinedValue><DefinedValue><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[Purchases]" Column="Total"></ColumnReference></DefinedValue></DefinedValues><Object Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[Purchases]" Index="[IX]" IndexKind="NonClustered" Storage="RowStore"></Object></IndexScan></RelOp></StreamAggregate></RelOp></Concat></RelOp></Sort></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 | 40 KB |
---|---|
Estimated Operator Cost | 0 (0%) |
Estimated Subtree Cost | 0.0459423 |
Degree of Parallelism | 0 |
Memory Grant | 1024 |
Estimated Number of Rows | 1 |
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.0000001 (0%) |
Estimated I/O Cost | 0 |
Estimated CPU Cost | 0.0000001 |
Estimated Subtree Cost | 0.0459423 |
Estimated Number of Executions | 1 |
Estimated Number of Rows | 1 |
Estimated Row Size | 27 B |
Node ID | 1 |
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 | 1 |
Actual Number of Batches | 0 |
Estimated Operator Cost | 0.0000017 (0%) |
Estimated I/O Cost | 0 |
Estimated CPU Cost | 0.0000017 |
Estimated Subtree Cost | 0.0459422 |
Estimated Number of Executions | 1 |
Number of Executions | 1 |
Estimated Number of Rows | 1 |
Estimated Row Size | 35 B |
Actual Rebinds | 0 |
Actual Rewinds | 0 |
Node ID | 2 |
Output List
Union1006
globalagg1011
globalagg1013
Sort
Cost: 25%
Sort
Sort the input.
Physical Operation | Sort |
---|---|
Logical Operation | Sort |
Actual Execution Mode | Row |
Estimated Execution Mode | Row |
Actual Number of Rows | 2 |
Actual Number of Batches | 0 |
Estimated Operator Cost | 0.0113644 (25%) |
Estimated I/O Cost | 0.0112613 |
Estimated CPU Cost | 0.0001032 |
Estimated Subtree Cost | 0.0459405 |
Estimated Number of Executions | 1 |
Number of Executions | 1 |
Estimated Number of Rows | 2 |
Estimated Row Size | 35 B |
Actual Rebinds | 1 |
Actual Rewinds | 0 |
Node ID | 3 |
Output List
Union1006
partialagg1010
partialagg1012
Order By
Union1006 Ascending
Concatenation
Cost: 0%
Concatenation
Physical Operation | Concatenation |
---|---|
Logical Operation | Concatenation |
Actual Execution Mode | Row |
Estimated Execution Mode | Row |
Actual Number of Rows | 2 |
Actual Number of Batches | 0 |
Estimated Operator Cost | 0.0000003 (0%) |
Estimated I/O Cost | 0 |
Estimated CPU Cost | 0.0000002 |
Estimated Subtree Cost | 0.0345761 |
Estimated Number of Executions | 1 |
Number of Executions | 1 |
Estimated Number of Rows | 2 |
Estimated Row Size | 35 B |
Actual Rebinds | 0 |
Actual Rewinds | 0 |
Node ID | 4 |
Output List
Union1006
partialagg1010
partialagg1012
Stream Aggregate
(Aggregate)
Cost: 3%
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 | 1 |
Actual Number of Batches | 0 |
Estimated Operator Cost | 0.0015449 (3%) |
Estimated I/O Cost | 0 |
Estimated CPU Cost | 0.0015449 |
Estimated Subtree Cost | 0.0172879 |
Estimated Number of Executions | 1 |
Number of Executions | 1 |
Estimated Number of Rows | 1 |
Estimated Row Size | 35 B |
Actual Rebinds | 0 |
Actual Rewinds | 0 |
Node ID | 5 |
Output List
[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a].[dbo].[SalesLedger].Date
partialagg1010
partialagg1012
Index Scan (NonClustered)
[SalesLedger].[IX]
Cost: 34%
Index Scan (NonClustered)
Physical Operation | Index Scan |
---|---|
Logical Operation | Index Scan |
Actual Execution Mode | Row |
Estimated Execution Mode | Row |
Storage | RowStore |
Number of Rows Read | 2574 |
Actual Number of Rows | 2574 |
Actual Number of Batches | 0 |
Estimated Operator Cost | 0.015743 (34%) |
Estimated I/O Cost | 0.0127546 |
Estimated CPU Cost | 0.0029884 |
Estimated Subtree Cost | 0.015743 |
Estimated Number of Executions | 1 |
Number of Executions | 1 |
Estimated Number of Rows to be Read | 2574 |
Estimated Number of Rows | 2574 |
Estimated Row Size | 27 B |
Actual Rebinds | 0 |
Actual Rewinds | 0 |
Ordered | True |
Node ID | 6 |
Output List
[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a].[dbo].[SalesLedger].Date
[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a].[dbo].[SalesLedger].Total
Object
[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a].[dbo].[SalesLedger].[IX]
Stream Aggregate
(Aggregate)
Cost: 3%
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 | 1 |
Actual Number of Batches | 0 |
Estimated Operator Cost | 0.0015449 (3%) |
Estimated I/O Cost | 0 |
Estimated CPU Cost | 0.0015449 |
Estimated Subtree Cost | 0.0172879 |
Estimated Number of Executions | 1 |
Number of Executions | 1 |
Estimated Number of Rows | 1 |
Estimated Row Size | 35 B |
Actual Rebinds | 0 |
Actual Rewinds | 0 |
Node ID | 7 |
Output List
[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a].[dbo].[Purchases].Date
partialagg1010
partialagg1012
Index Scan (NonClustered)
[Purchases].[IX]
Cost: 34%
Index Scan (NonClustered)
Physical Operation | Index Scan |
---|---|
Logical Operation | Index Scan |
Actual Execution Mode | Row |
Estimated Execution Mode | Row |
Storage | RowStore |
Number of Rows Read | 2574 |
Actual Number of Rows | 2574 |
Actual Number of Batches | 0 |
Estimated Operator Cost | 0.015743 (34%) |
Estimated I/O Cost | 0.0127546 |
Estimated CPU Cost | 0.0029884 |
Estimated Subtree Cost | 0.015743 |
Estimated Number of Executions | 1 |
Number of Executions | 1 |
Estimated Number of Rows to be Read | 2574 |
Estimated Number of Rows | 2574 |
Estimated Row Size | 27 B |
Actual Rebinds | 0 |
Actual Rewinds | 0 |
Ordered | True |
Node ID | 8 |
Output List
[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a].[dbo].[Purchases].Date
[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a].[dbo].[Purchases].Total
Object
[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a].[dbo].[Purchases].[IX]
(No column name) | Date |
---|---|
9211907894.000000000000000000 | 2023-08-28 |
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.0401799" StatementEstRows="1" 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="48" CompileTime="15" CompileCPU="15" CompileMemory="640"><MemoryGrantInfo SerialRequiredMemory="0" SerialDesiredMemory="0" GrantedMemory="0" MaxUsedMemory="0"></MemoryGrantInfo><OptimizerHardwareDependentProperties EstimatedAvailableMemoryGrant="1258238" EstimatedPagesCached="78639" EstimatedAvailableDegreeOfParallelism="1" MaxCompileMemory="1409224"></OptimizerHardwareDependentProperties><OptimizerStatsUsage><StatisticsInfo LastUpdate="2023-08-28T01:46:15.86" ModificationCount="0" SamplingPercent="100" Statistics="[IX]" Table="[Purchases]" Schema="[dbo]" Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]"></StatisticsInfo><StatisticsInfo LastUpdate="2023-08-28T01:46:15.86" ModificationCount="0" SamplingPercent="100" Statistics="[IX]" Table="[SalesLedger]" Schema="[dbo]" Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]"></StatisticsInfo></OptimizerStatsUsage><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.0401799" 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" EstimateIO="0" EstimateCPU="1.7e-06" AvgRowSize="27" EstimatedTotalSubtreeCost="0.0401799" 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="1" 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.0401782" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Column="Union1006"></ColumnReference><ColumnReference Column="Expr1009"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="2" 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_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[SalesLedger]" Column="Date"></ColumnReference><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" 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.0172879" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" 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="0.0015449" AvgRowSize="27" EstimatedTotalSubtreeCost="0.0172879" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[SalesLedger]" Column="Date"></ColumnReference><ColumnReference Column="Expr1027"></ColumnReference><ColumnReference Column="Expr1028"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="1" 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_ec3af89e67f24d15bbb3da76c5b91a2a].[dbo].[SalesLedger].[Total])"><Aggregate Distinct="0" AggType="COUNT_BIG"><ScalarOperator><Identifier><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[SalesLedger]" Column="Total"></ColumnReference></Identifier></ScalarOperator></Aggregate></ScalarOperator></DefinedValue><DefinedValue><ColumnReference Column="Expr1028"></ColumnReference><ScalarOperator ScalarString="SUM([fiddle_ec3af89e67f24d15bbb3da76c5b91a2a].[dbo].[SalesLedger].[Total])"><Aggregate Distinct="0" AggType="SUM"><ScalarOperator><Identifier><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[SalesLedger]" Column="Total"></ColumnReference></Identifier></ScalarOperator></Aggregate></ScalarOperator></DefinedValue></DefinedValues><GroupBy><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[SalesLedger]" Column="Date"></ColumnReference></GroupBy><RelOp NodeId="5" PhysicalOp="Index Scan" LogicalOp="Index Scan" EstimateRows="2574" EstimatedRowsRead="2574" EstimateIO="0.0127546" EstimateCPU="0.0029884" AvgRowSize="27" EstimatedTotalSubtreeCost="0.015743" TableCardinality="2574" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[SalesLedger]" Column="Date"></ColumnReference><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[SalesLedger]" Column="Total"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="2574" Batches="0" ActualElapsedms="0" ActualCPUms="0" ActualScans="1" ActualLogicalReads="16" ActualPhysicalReads="0" ActualReadAheads="0" ActualLobLogicalReads="0" ActualLobPhysicalReads="0" ActualLobReadAheads="0" ActualRowsRead="2574" 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_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[SalesLedger]" Column="Date"></ColumnReference></DefinedValue><DefinedValue><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[SalesLedger]" Column="Total"></ColumnReference></DefinedValue></DefinedValues><Object Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" 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.0172879" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" 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="0.0015449" AvgRowSize="27" EstimatedTotalSubtreeCost="0.0172879" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[Purchases]" Column="Date"></ColumnReference><ColumnReference Column="Expr1029"></ColumnReference><ColumnReference Column="Expr1030"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="1" 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_ec3af89e67f24d15bbb3da76c5b91a2a].[dbo].[Purchases].[Total])"><Aggregate Distinct="0" AggType="COUNT_BIG"><ScalarOperator><Identifier><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[Purchases]" Column="Total"></ColumnReference></Identifier></ScalarOperator></Aggregate></ScalarOperator></DefinedValue><DefinedValue><ColumnReference Column="Expr1030"></ColumnReference><ScalarOperator ScalarString="SUM([fiddle_ec3af89e67f24d15bbb3da76c5b91a2a].[dbo].[Purchases].[Total])"><Aggregate Distinct="0" AggType="SUM"><ScalarOperator><Identifier><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[Purchases]" Column="Total"></ColumnReference></Identifier></ScalarOperator></Aggregate></ScalarOperator></DefinedValue></DefinedValues><GroupBy><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[Purchases]" Column="Date"></ColumnReference></GroupBy><RelOp NodeId="8" PhysicalOp="Index Scan" LogicalOp="Index Scan" EstimateRows="2574" EstimatedRowsRead="2574" EstimateIO="0.0127546" EstimateCPU="0.0029884" AvgRowSize="27" EstimatedTotalSubtreeCost="0.015743" TableCardinality="2574" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[Purchases]" Column="Date"></ColumnReference><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[Purchases]" Column="Total"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="2574" Batches="0" ActualElapsedms="0" ActualCPUms="0" ActualScans="1" ActualLogicalReads="16" ActualPhysicalReads="0" ActualReadAheads="0" ActualLobLogicalReads="0" ActualLobPhysicalReads="0" ActualLobReadAheads="0" ActualRowsRead="2574" 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_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[Purchases]" Column="Date"></ColumnReference></DefinedValue><DefinedValue><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[Purchases]" Column="Total"></ColumnReference></DefinedValue></DefinedValues><Object Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" 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 | 48 KB |
---|---|
Estimated Operator Cost | 0 (0%) |
Estimated Subtree Cost | 0.0401799 |
Degree of Parallelism | 0 |
Estimated Number of Rows | 1 |
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.0401799 |
Estimated Number of Executions | 1 |
Estimated Number of Rows | 1 |
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 | 1 |
Actual Number of Batches | 0 |
Estimated Operator Cost | 0.0000017 (0%) |
Estimated I/O Cost | 0 |
Estimated CPU Cost | 0.0000017 |
Estimated Subtree Cost | 0.0401799 |
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
Expr1031
Expr1032
Merge Join
(Concatenation)
Cost: 14%
Merge Join
Physical Operation | Merge Join |
---|---|
Logical Operation | Concatenation |
Actual Execution Mode | Row |
Estimated Execution Mode | Row |
Actual Number of Rows | 2 |
Actual Number of Batches | 0 |
Estimated Operator Cost | 0.0056024 (14%) |
Estimated I/O Cost | 0 |
Estimated CPU Cost | 0.0056023 |
Estimated Subtree Cost | 0.0401782 |
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.0172879 |
Estimated Number of Executions | 1 |
Estimated Number of Rows | 1 |
Estimated Row Size | 27 B |
Node ID | 3 |
Output List
[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a].[dbo].[SalesLedger].Date
Expr1009
Stream Aggregate
(Aggregate)
Cost: 4%
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 | 1 |
Actual Number of Batches | 0 |
Estimated Operator Cost | 0.0015449 (4%) |
Estimated I/O Cost | 0 |
Estimated CPU Cost | 0.0015449 |
Estimated Subtree Cost | 0.0172879 |
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_ec3af89e67f24d15bbb3da76c5b91a2a].[dbo].[SalesLedger].Date
Expr1027
Expr1028
Index Scan (NonClustered)
[SalesLedger].[IX]
Cost: 39%
Index Scan (NonClustered)
Physical Operation | Index Scan |
---|---|
Logical Operation | Index Scan |
Actual Execution Mode | Row |
Estimated Execution Mode | Row |
Storage | RowStore |
Number of Rows Read | 2574 |
Actual Number of Rows | 2574 |
Actual Number of Batches | 0 |
Estimated Operator Cost | 0.015743 (39%) |
Estimated I/O Cost | 0.0127546 |
Estimated CPU Cost | 0.0029884 |
Estimated Subtree Cost | 0.015743 |
Estimated Number of Executions | 1 |
Number of Executions | 1 |
Estimated Number of Rows to be Read | 2574 |
Estimated Number of Rows | 2574 |
Estimated Row Size | 27 B |
Actual Rebinds | 0 |
Actual Rewinds | 0 |
Ordered | True |
Node ID | 5 |
Output List
[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a].[dbo].[SalesLedger].Date
[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a].[dbo].[SalesLedger].Total
Object
[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a].[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.0172879 |
Estimated Number of Executions | 1 |
Estimated Number of Rows | 1 |
Estimated Row Size | 27 B |
Node ID | 6 |
Output List
[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a].[dbo].[Purchases].Date
Expr1009
Stream Aggregate
(Aggregate)
Cost: 4%
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 | 1 |
Actual Number of Batches | 0 |
Estimated Operator Cost | 0.0015449 (4%) |
Estimated I/O Cost | 0 |
Estimated CPU Cost | 0.0015449 |
Estimated Subtree Cost | 0.0172879 |
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_ec3af89e67f24d15bbb3da76c5b91a2a].[dbo].[Purchases].Date
Expr1029
Expr1030
Index Scan (NonClustered)
[Purchases].[IX]
Cost: 39%
Index Scan (NonClustered)
Physical Operation | Index Scan |
---|---|
Logical Operation | Index Scan |
Actual Execution Mode | Row |
Estimated Execution Mode | Row |
Storage | RowStore |
Number of Rows Read | 2574 |
Actual Number of Rows | 2574 |
Actual Number of Batches | 0 |
Estimated Operator Cost | 0.015743 (39%) |
Estimated I/O Cost | 0.0127546 |
Estimated CPU Cost | 0.0029884 |
Estimated Subtree Cost | 0.015743 |
Estimated Number of Executions | 1 |
Number of Executions | 1 |
Estimated Number of Rows to be Read | 2574 |
Estimated Number of Rows | 2574 |
Estimated Row Size | 27 B |
Actual Rebinds | 0 |
Actual Rewinds | 0 |
Ordered | True |
Node ID | 8 |
Output List
[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a].[dbo].[Purchases].Date
[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a].[dbo].[Purchases].Total
Object
[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a].[dbo].[Purchases].[IX]
Sales | Date |
---|---|
4605953947.000000000000000000 | 2023-08-28 |
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.0187808" 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="336"><MemoryGrantInfo SerialRequiredMemory="0" SerialDesiredMemory="0" GrantedMemory="0" MaxUsedMemory="0"></MemoryGrantInfo><OptimizerHardwareDependentProperties EstimatedAvailableMemoryGrant="1258238" EstimatedPagesCached="78639" EstimatedAvailableDegreeOfParallelism="1" MaxCompileMemory="1409224"></OptimizerHardwareDependentProperties><OptimizerStatsUsage><StatisticsInfo LastUpdate="2023-08-28T01:46:15.86" ModificationCount="0" SamplingPercent="100" Statistics="[IX]" Table="[SalesLedger]" Schema="[dbo]" Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]"></StatisticsInfo></OptimizerStatsUsage><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.0187808" 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="0.0015449" AvgRowSize="27" EstimatedTotalSubtreeCost="0.0187808" 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="1" 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_ec3af89e67f24d15bbb3da76c5b91a2a].[dbo].[SalesLedger].[Total])"><Aggregate Distinct="0" AggType="COUNT_BIG"><ScalarOperator><Identifier><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[SalesLedger]" Column="Total"></ColumnReference></Identifier></ScalarOperator></Aggregate></ScalarOperator></DefinedValue><DefinedValue><ColumnReference Column="Expr1015"></ColumnReference><ScalarOperator ScalarString="SUM([fiddle_ec3af89e67f24d15bbb3da76c5b91a2a].[dbo].[SalesLedger].[Total])"><Aggregate Distinct="0" AggType="SUM"><ScalarOperator><Identifier><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" 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="2574" EstimateIO="0" EstimateCPU="0.00123552" AvgRowSize="30" EstimatedTotalSubtreeCost="0.0172359" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[SalesLedger]" Column="Date"></ColumnReference><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[SalesLedger]" Column="Total"></ColumnReference><ColumnReference Column="Union1006"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="2574" 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="2574" EstimateIO="0" EstimateCPU="0.0002574" AvgRowSize="30" EstimatedTotalSubtreeCost="0.0160004" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[SalesLedger]" Column="Date"></ColumnReference><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[SalesLedger]" Column="Total"></ColumnReference><ColumnReference Column="Union1006"></ColumnReference></OutputList><ComputeScalar><DefinedValues><DefinedValue><ColumnReference Column="Union1006"></ColumnReference><ScalarOperator ScalarString="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a].[dbo].[SalesLedger].[Date]"><Identifier><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[SalesLedger]" Column="Date"></ColumnReference></Identifier></ScalarOperator></DefinedValue></DefinedValues><RelOp NodeId="4" PhysicalOp="Index Scan" LogicalOp="Index Scan" EstimateRows="2574" EstimatedRowsRead="2574" EstimateIO="0.0127546" EstimateCPU="0.0029884" AvgRowSize="27" EstimatedTotalSubtreeCost="0.015743" TableCardinality="2574" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[SalesLedger]" Column="Date"></ColumnReference><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[SalesLedger]" Column="Total"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="2574" Batches="0" ActualElapsedms="0" ActualCPUms="0" ActualScans="1" ActualLogicalReads="16" ActualPhysicalReads="0" ActualReadAheads="0" ActualLobLogicalReads="0" ActualLobPhysicalReads="0" ActualLobReadAheads="0" ActualRowsRead="2574" 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_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[SalesLedger]" Column="Date"></ColumnReference></DefinedValue><DefinedValue><ColumnReference Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" Schema="[dbo]" Table="[SalesLedger]" Column="Total"></ColumnReference></DefinedValue></DefinedValues><Object Database="[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a]" 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.0187808 |
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.0187808 |
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: 8%
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 | 1 |
Actual Number of Batches | 0 |
Estimated Operator Cost | 0.0015449 (8%) |
Estimated I/O Cost | 0 |
Estimated CPU Cost | 0.0015449 |
Estimated Subtree Cost | 0.0187808 |
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: 7%
Filter
Physical Operation | Filter |
---|---|
Logical Operation | Filter |
Actual Execution Mode | Row |
Estimated Execution Mode | Row |
Actual Number of Rows | 2574 |
Actual Number of Batches | 0 |
Estimated Operator Cost | 0.0012355 (7%) |
Estimated I/O Cost | 0 |
Estimated CPU Cost | 0.0012355 |
Estimated Subtree Cost | 0.0172359 |
Estimated Number of Executions | 1 |
Number of Executions | 1 |
Estimated Number of Rows | 2574 |
Estimated Row Size | 30 B |
Actual Rebinds | 1 |
Actual Rewinds | 0 |
Node ID | 2 |
Output List
[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a].[dbo].[SalesLedger].Date
[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a].[dbo].[SalesLedger].Total
Union1006
Predicate
'Sale'='Sale'
Compute Scalar
Cost: 1%
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.0002574 (1%) |
Estimated I/O Cost | 0 |
Estimated CPU Cost | 0.0002574 |
Estimated Subtree Cost | 0.0160004 |
Estimated Number of Executions | 1 |
Estimated Number of Rows | 2574 |
Estimated Row Size | 30 B |
Node ID | 3 |
Output List
[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a].[dbo].[SalesLedger].Date
[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a].[dbo].[SalesLedger].Total
Union1006
Index Scan (NonClustered)
[SalesLedger].[IX]
Cost: 84%
Index Scan (NonClustered)
Physical Operation | Index Scan |
---|---|
Logical Operation | Index Scan |
Actual Execution Mode | Row |
Estimated Execution Mode | Row |
Storage | RowStore |
Number of Rows Read | 2574 |
Actual Number of Rows | 2574 |
Actual Number of Batches | 0 |
Estimated Operator Cost | 0.015743 (84%) |
Estimated I/O Cost | 0.0127546 |
Estimated CPU Cost | 0.0029884 |
Estimated Subtree Cost | 0.015743 |
Estimated Number of Executions | 1 |
Number of Executions | 1 |
Estimated Number of Rows to be Read | 2574 |
Estimated Number of Rows | 2574 |
Estimated Row Size | 27 B |
Actual Rebinds | 0 |
Actual Rewinds | 0 |
Ordered | True |
Node ID | 4 |
Output List
[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a].[dbo].[SalesLedger].Date
[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a].[dbo].[SalesLedger].Total
Object
[fiddle_ec3af89e67f24d15bbb3da76c5b91a2a].[dbo].[SalesLedger].[IX]