Created
March 11, 2016 16:15
-
-
Save swasheck/c2d5177d24cf4da2d617 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select getdate() , | |
schema_name = sh.name , | |
table_name = t.name , | |
stat_name = s.name , | |
index_name = i.name , | |
stat_leading_column = | |
index_col(quotename(sh.name) + '.' + quotename(t.name), | |
s.stats_id, 1) , | |
s.stats_id , | |
s.has_filter , | |
s.auto_created , | |
sp.last_updated , | |
sp.rows , | |
sp.rows_sampled , | |
sp.unfiltered_rows , | |
sp.modification_counter , | |
mod_pct = ( 100. * sp.modification_counter ) | |
/ sp.unfiltered_rows , | |
[default_mod_threshold] = case when sp.unfiltered_rows < 500 | |
then 500 | |
else ( .20 | |
* sp.unfiltered_rows | |
+ 500 ) | |
end , | |
[2371_mod_threshold] = sqrt(1000 * sp.unfiltered_rows) , | |
default_mod_hit = case when sp.modification_counter > case | |
when sp.unfiltered_rows < 500 | |
then 500 | |
else ( .20 | |
* sp.unfiltered_rows | |
+ 500 ) | |
end then 1 | |
else 0 | |
end , | |
[2371_mod_hit] = case when sp.modification_counter > sqrt(1000 | |
* sp.unfiltered_rows) | |
then 1 | |
else 0 | |
end | |
from sys.stats s | |
join sys.tables t on s.object_id = t.object_id | |
join sys.schemas sh on t.schema_id = sh.schema_id | |
left join sys.indexes i on s.object_id = i.object_id | |
and s.name = i.name | |
cross apply sys.dm_db_stats_properties(s.object_id, | |
s.stats_id) sp; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment