I am trying to simulate a plan recompilation due to auto update stats which is triggered when threshold(500 + 20 percent modifications) reached.
database current settings are:
I started with creating a simple table:
create table recomp(num int)
go
Then I insert some rows:
insert into recomp
values (5)
go 100
and run my query below 5 times (I used where 1 = (select 1)) for full optimization:
select * from recomp
where 1 = (select 1)
in my plan cache I have the following:
Now the interesting part, I again insert new rows in order to trigger auto update stats for num column of the recomp table:
insert into recomp
values (8)
go 500
Here stats for num column has updated. The next what I am going to do is run my select query:
select * from recomp
where 1 = (select 1)
When I check my plan cache:
and an event which captures recompiles:
my question is: where can I find stats for num column?
Best Answer
The optimizer doen't need any stats to optimize those queries, so none are created.
AUTO_CREATE_STATISTICS Option
Try something like
And you should see a statistic created.