Puzzle CE

Sql server 2019, I have this query, and I was wondered from where is coming the estimate of 19140:

select
rezProcesat
from tblRezervari
where 1=1
and rezProcesat is null
OPTION
(
QUERYTRACEON 3604, QUERYTRACEON 2363 –New CE Stats Report
)

And the estimate for it is: 19140


the output from TF2363 :

Begin selectivity computation

Input tree:

LogOp_Select

  CStCollBaseTable(ID=1, CARD=1.84981e+07 TBL: tblRezervari)

  ScaOp_Comp x_cmpIs

      ScaOp_Identifier QCOL: [Stefan_2019].[dbo].[tblRezervari].rezProcesat

      ScaOp_Const TI(datetime,Null,ML=8) XVAR(datetime,Not Owned,Value=NULL)

Plan for computation:

CSelCalcColumnInInterval

  Column: QCOL: [Stefan_2019].[dbo].[tblRezervari].rezProcesat

Loaded histogram for column COL: KeyCo2 from stats with id 13

Selectivity: 0.00103472

Stats collection generated:

CStCollFilter(ID=2, CARD=19140.4)

  CStCollBaseTable(ID=1, CARD=1.84981e+07 TBL: tblRezervari)

End selectivity computation


So, the value 19140 is base on 0.00103472 * 1.84981e+07


But , from where did we get the Selectivity: 0.00103472 ?
I have a filtered index on that column, with filtered clause on exact that predicate.



Now, the next value : CARD=1.84981e+07, translated to 18498100

This should be the cardinality of the table… but I don’t from where is that value.


I don’t exactly know from where the exact value 18498100 come from , but this probably would be a future post after more research

S

Leave a comment