clear markdown compare help donate or buy diddy dollings comments/suggestions/bugs a leap of faith? bible365
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 809155 fiddles created (9808 in the last week).

-------------------------------------------------------------------------------- -- ② Integers table -------------------------------------------------------------------------------- with p0(i) as (select 1 union all select 1 union all select 1 union all select 1) , p1(i) as (select 1 from p0 as a, p0 as b, p0 as c, p0 as d, p0 as e)--1K rows , p2(i) as (select 1 from p1 as a, p1 as b)--1M rows select row_number() over(order by i) as val into integers from p2
1048576 rows affected
 hidden batch(es)


CREATE TABLE dbo.TestIndexSample ( Code char(4) NOT NULL, Name nvarchar(200) NOT NULL, ModifiedDate datetime NOT NULL CONSTRAINT [DF_TestIndexSample_ModifiedDate] DEFAULT GETDATE(), CONSTRAINT [PK_TestIndexSample_Code] PRIMARY KEY CLUSTERED(Code) ); CREATE NONCLUSTERED INDEX IX_TestIndexSample_Name ON dbo.TestIndexSample(Name); INSERT INTO dbo.TestIndexSample(Code, Name) SELECT CAST(val as CHAR(4)), 'NAME' + CAST(val as VARCHAR(10)) FROM integers WHERE val <= 321 ORDER BY val;
321 rows affected
 hidden batch(es)


set statistics xml on; SELECT Code,Name,ModifiedDate FROM dbo.TestIndexSample WITH(INDEX (IX_TestIndexSample_Name)) WHERE Name = 'NAME10';
Code Name ModifiedDate
10 NAME10 2020-02-21 10:33:49.023
Microsoft SQL Server 2005 XML Showplan
<ShowPlanXML xmlns="http://schemas.microsoft.com/sqlserver/2004/07/showplan" Version="1.481" Build="14.0.3192.2"><BatchSequence><Batch><Statements><StmtSimple StatementText="SELECT Code,Name,ModifiedDate &#xa;FROM dbo.TestIndexSample WITH(INDEX (IX_TestIndexSample_Name))&#xa;WHERE Name = &apos;NAME10&apos;" StatementId="1" StatementCompId="2" StatementType="SELECT" RetrievedFromCache="true" StatementSubTreeCost="0.00657038" StatementEstRows="1" SecurityPolicyApplied="false" StatementOptmLevel="FULL" QueryHash="0x415119FDA6F70F7B" QueryPlanHash="0x04E508B37045F88C" StatementOptmEarlyAbortReason="GoodEnoughPlanFound" CardinalityEstimationModelVersion="140"><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="192"><MemoryGrantInfo SerialRequiredMemory="0" SerialDesiredMemory="0"></MemoryGrantInfo><OptimizerHardwareDependentProperties EstimatedAvailableMemoryGrant="838808" EstimatedPagesCached="52425" EstimatedAvailableDegreeOfParallelism="1" MaxCompileMemory="1290720"></OptimizerHardwareDependentProperties><OptimizerStatsUsage><StatisticsInfo LastUpdate="2020-02-21T10:33:49.10" ModificationCount="0" SamplingPercent="100" Statistics="[IX_TestIndexSample_Name]" Table="[TestIndexSample]" Schema="[dbo]" Database="[fiddle_fef84944893146d08702f9377362cbdc]"></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="Nested Loops" LogicalOp="Inner Join" EstimateRows="1" EstimateIO="0" EstimateCPU="4.18e-006" AvgRowSize="36" EstimatedTotalSubtreeCost="0.00657038" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_fef84944893146d08702f9377362cbdc]" Schema="[dbo]" Table="[TestIndexSample]" Column="Code"></ColumnReference><ColumnReference Database="[fiddle_fef84944893146d08702f9377362cbdc]" Schema="[dbo]" Table="[TestIndexSample]" Column="Name"></ColumnReference><ColumnReference Database="[fiddle_fef84944893146d08702f9377362cbdc]" Schema="[dbo]" Table="[TestIndexSample]" Column="ModifiedDate"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="1" Batches="0" ActualExecutionMode="Row" ActualElapsedms="0" ActualCPUms="0" ActualEndOfScans="1" ActualExecutions="1"></RunTimeCountersPerThread></RunTimeInformation><NestedLoops Optimized="0"><OuterReferences><ColumnReference Database="[fiddle_fef84944893146d08702f9377362cbdc]" Schema="[dbo]" Table="[TestIndexSample]" Column="Code"></ColumnReference></OuterReferences><RelOp NodeId="1" PhysicalOp="Index Seek" LogicalOp="Index Seek" EstimateRows="1" EstimatedRowsRead="1" EstimateIO="0.003125" EstimateCPU="0.0001581" AvgRowSize="28" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="321" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_fef84944893146d08702f9377362cbdc]" Schema="[dbo]" Table="[TestIndexSample]" Column="Code"></ColumnReference><ColumnReference Database="[fiddle_fef84944893146d08702f9377362cbdc]" Schema="[dbo]" Table="[TestIndexSample]" Column="Name"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="1" Batches="0" ActualExecutionMode="Row" ActualElapsedms="0" ActualCPUms="0" ActualScans="1" ActualLogicalReads="2" ActualPhysicalReads="0" ActualReadAheads="0" ActualLobLogicalReads="0" ActualLobPhysicalReads="0" ActualLobReadAheads="0" ActualRowsRead="1" ActualEndOfScans="1" ActualExecutions="1"></RunTimeCountersPerThread></RunTimeInformation><IndexScan Ordered="1" ScanDirection="FORWARD" ForcedIndex="1" ForceSeek="0" ForceScan="0" NoExpandHint="0" Storage="RowStore"><DefinedValues><DefinedValue><ColumnReference Database="[fiddle_fef84944893146d08702f9377362cbdc]" Schema="[dbo]" Table="[TestIndexSample]" Column="Code"></ColumnReference></DefinedValue><DefinedValue><ColumnReference Database="[fiddle_fef84944893146d08702f9377362cbdc]" Schema="[dbo]" Table="[TestIndexSample]" Column="Name"></ColumnReference></DefinedValue></DefinedValues><Object Database="[fiddle_fef84944893146d08702f9377362cbdc]" Schema="[dbo]" Table="[TestIndexSample]" Index="[IX_TestIndexSample_Name]" IndexKind="NonClustered" Storage="RowStore"></Object><SeekPredicates><SeekPredicateNew><SeekKeys><Prefix ScanType="EQ"><RangeColumns><ColumnReference Database="[fiddle_fef84944893146d08702f9377362cbdc]" Schema="[dbo]" Table="[TestIndexSample]" Column="Name"></ColumnReference></RangeColumns><RangeExpressions><ScalarOperator ScalarString="N&apos;NAME10&apos;"><Const ConstValue="N&apos;NAME10&apos;"></Const></ScalarOperator></RangeExpressions></Prefix></SeekKeys></SeekPredicateNew></SeekPredicates></IndexScan></RelOp><RelOp NodeId="3" PhysicalOp="Clustered Index Seek" LogicalOp="Clustered Index Seek" EstimateRows="1" EstimateIO="0.003125" EstimateCPU="0.0001581" AvgRowSize="15" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="321" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_fef84944893146d08702f9377362cbdc]" Schema="[dbo]" Table="[TestIndexSample]" Column="ModifiedDate"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="1" Batches="0" ActualExecutionMode="Row" ActualElapsedms="0" ActualCPUms="0" ActualScans="0" ActualLogicalReads="2" ActualPhysicalReads="0" ActualReadAheads="0" ActualLobLogicalReads="0" ActualLobPhysicalReads="0" ActualLobReadAheads="0" ActualRowsRead="1" ActualEndOfScans="0" ActualExecutions="1"></RunTimeCountersPerThread></RunTimeInformation><IndexScan Lookup="1" Ordered="1" ScanDirection="FORWARD" ForcedIndex="1" ForceSeek="0" ForceScan="0" NoExpandHint="0" Storage="RowStore"><DefinedValues><DefinedValue><ColumnReference Database="[fiddle_fef84944893146d08702f9377362cbdc]" Schema="[dbo]" Table="[TestIndexSample]" Column="ModifiedDate"></ColumnReference></DefinedValue></DefinedValues><Object Database="[fiddle_fef84944893146d08702f9377362cbdc]" Schema="[dbo]" Table="[TestIndexSample]" Index="[PK_TestIndexSample_Code]" TableReferenceId="-1" IndexKind="Clustered" Storage="RowStore"></Object><SeekPredicates><SeekPredicateNew><SeekKeys><Prefix ScanType="EQ"><RangeColumns><ColumnReference Database="[fiddle_fef84944893146d08702f9377362cbdc]" Schema="[dbo]" Table="[TestIndexSample]" Column="Code"></ColumnReference></RangeColumns><RangeExpressions><ScalarOperator ScalarString="[fiddle_fef84944893146d08702f9377362cbdc].[dbo].[TestIndexSample].[Code]"><Identifier><ColumnReference Database="[fiddle_fef84944893146d08702f9377362cbdc]" Schema="[dbo]" Table="[TestIndexSample]" Column="Code"></ColumnReference></Identifier></ScalarOperator></RangeExpressions></Prefix></SeekKeys></SeekPredicateNew></SeekPredicates></IndexScan></RelOp></NestedLoops></RelOp></QueryPlan></StmtSimple></Statements></Batch></BatchSequence></ShowPlanXML>
 hidden batch(es)


SELECT Name FROM dbo.TestIndexSample WHERE Name = 'NAME10';
Name
NAME10
Microsoft SQL Server 2005 XML Showplan
<ShowPlanXML xmlns="http://schemas.microsoft.com/sqlserver/2004/07/showplan" Version="1.481" Build="14.0.3192.2"><BatchSequence><Batch><Statements><StmtSimple StatementText="SELECT [Name] FROM [dbo].[TestIndexSample] WHERE [Name]=@1" StatementId="1" StatementCompId="1" StatementType="SELECT" RetrievedFromCache="true" StatementSubTreeCost="0.0032831" StatementEstRows="1" SecurityPolicyApplied="false" StatementOptmLevel="TRIVIAL" QueryHash="0x1E8C56689C0FB4E1" QueryPlanHash="0x9A333594F518338F" CardinalityEstimationModelVersion="140"><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="160"><MemoryGrantInfo SerialRequiredMemory="0" SerialDesiredMemory="0"></MemoryGrantInfo><OptimizerHardwareDependentProperties EstimatedAvailableMemoryGrant="838808" EstimatedPagesCached="52425" EstimatedAvailableDegreeOfParallelism="1" MaxCompileMemory="1290720"></OptimizerHardwareDependentProperties><OptimizerStatsUsage><StatisticsInfo LastUpdate="2020-02-21T10:33:49.10" ModificationCount="0" SamplingPercent="100" Statistics="[IX_TestIndexSample_Name]" Table="[TestIndexSample]" Schema="[dbo]" Database="[fiddle_fef84944893146d08702f9377362cbdc]"></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="Index Seek" LogicalOp="Index Seek" EstimateRows="1" EstimatedRowsRead="1" EstimateIO="0.003125" EstimateCPU="0.0001581" AvgRowSize="24" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="321" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_fef84944893146d08702f9377362cbdc]" Schema="[dbo]" Table="[TestIndexSample]" Column="Name"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="1" Batches="0" ActualExecutionMode="Row" ActualElapsedms="0" ActualCPUms="0" ActualScans="1" ActualLogicalReads="2" ActualPhysicalReads="0" ActualReadAheads="0" ActualLobLogicalReads="0" ActualLobPhysicalReads="0" ActualLobReadAheads="0" ActualRowsRead="1" ActualEndOfScans="1" ActualExecutions="1"></RunTimeCountersPerThread></RunTimeInformation><IndexScan Ordered="1" ScanDirection="FORWARD" ForcedIndex="0" ForceSeek="0" ForceScan="0" NoExpandHint="0" Storage="RowStore"><DefinedValues><DefinedValue><ColumnReference Database="[fiddle_fef84944893146d08702f9377362cbdc]" Schema="[dbo]" Table="[TestIndexSample]" Column="Name"></ColumnReference></DefinedValue></DefinedValues><Object Database="[fiddle_fef84944893146d08702f9377362cbdc]" Schema="[dbo]" Table="[TestIndexSample]" Index="[IX_TestIndexSample_Name]" IndexKind="NonClustered" Storage="RowStore"></Object><SeekPredicates><SeekPredicateNew><SeekKeys><Prefix ScanType="EQ"><RangeColumns><ColumnReference Database="[fiddle_fef84944893146d08702f9377362cbdc]" Schema="[dbo]" Table="[TestIndexSample]" Column="Name"></ColumnReference></RangeColumns><RangeExpressions><ScalarOperator ScalarString="CONVERT_IMPLICIT(nvarchar(4000),[@1],0)"><Identifier><ColumnReference Column="ConstExpr1002"><ScalarOperator><Convert DataType="nvarchar" Length="8000" Style="0" Implicit="1"><ScalarOperator><Identifier><ColumnReference Column="@1"></ColumnReference></Identifier></ScalarOperator></Convert></ScalarOperator></ColumnReference></Identifier></ScalarOperator></RangeExpressions></Prefix></SeekKeys></SeekPredicateNew></SeekPredicates></IndexScan></RelOp><ParameterList><ColumnReference Column="@1" ParameterDataType="varchar(8000)" ParameterCompiledValue="&apos;NAME10&apos;" ParameterRuntimeValue="&apos;NAME10&apos;"></ColumnReference></ParameterList></QueryPlan></StmtSimple></Statements></Batch></BatchSequence></ShowPlanXML>
 hidden batch(es)