Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Administration - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 6525

Estimated rows seems to be incorrect

$
0
0
I have come across an issue where the estimated rows dont appear to be what they should be. I may misunderstand how estimated are derived so I am just looking for some clarification. I will apologize in advanced for not being able to supply a working demo of the issue as I have not been able to re-create is in any other database but same issue occurs in any table I have tried within database.The server is 2014 RTM-CU10 (cant update to SP1 because application not certified yet) and the server collation is Latin1_General_BIN.here is an example of table[code="sql"]CREATE TABLE [dbo].[PERSON]( [ID] [varchar](10) NOT NULL, [FIRST_NAME] [varchar](30) NULL,CONSTRAINT [PK_PERSON] PRIMARY KEY CLUSTERED ([ID] ASC))CREATE NONCLUSTERED INDEX [IX_PERSON_FIRST_NAME] ON [dbo].[PERSON]([FIRST_NAME] ASC)WITH (FILLFACTOR = 80) [/code]below is an excerpt from the histogram when running DBCC Show_statistics('PERSON','IX_PERSON_FIRST_NAME')[quote]RANGE_HI_KEY RANGE_ROWS EQ_ROWS DISTINCT_RANGE_ROWS AVG_RANGE_ROWSLaurie 535 219 140 3.821429Lee 980 153 233 4.206008Leslie 1393 250 360 3.869444Linda 956 825 316 3.025316[/quote]now when I run the following query I get 153 estimated rows. [code="sql"]SELECT ID,FIRST_NAMEFROM PERSONWHERE FIRST_NAME = 'Lee David' OPTION(RECOMPILE)[/code][code="xml"]<RelOp AvgRowSize="24" EstimateCPU="0.0003253" EstimateIO="0.003125" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row" [b]EstimateRows="153"[/b] LogicalOp="Index Seek" NodeId="0" Parallel="false" PhysicalOp="Index Seek" EstimatedTotalSubtreeCost="0.0034503" TableCardinality="268380">[/code]Books online states the [url=https://msdn.microsoft.com/en-us/library/ms174384.aspx]RANGE_HI_KEY is "Upper bound column value for a histogram step"[/url] so shouldn't the predicate "Lee David" fall into the next step(RANGE_HI_KEY = Leslie) and have an estimate of 3.869444.Am I misunderstanding how this should work or is this not working the way it should? Thanks

Viewing all articles
Browse latest Browse all 6525

Trending Articles