Answered by:
is statistic are created auto matically.

Question
-
hi,
need some confermation.
1) i have seen statistices are created automatically , even if there is no index?
2) i have created few statistics using database tuning adviser recomendation,
is there any possibility,that sqlserver will create same statistics with diffrent name again ?
yours sincerly
Friday, March 7, 2014 7:04 AM
Answers
-
For a very comprehensive and Free guide to SQL Server statistics, see the Whitepaper:
Statistics Used by the Query Optimizer
With regard to your specific questions:
- Yes. What you are referring to are column statistics.
- Yes. The query optimizer determines if statistics would be "helpful" for a given query and if so creates them. Therefore as your queries/workload profile changes, so to can the column statistics that are created.
Again, the whitepaper contains a more detailed explanation.
John Sansom | SQL Server MCM
Blog | Twitter | LinkedIn | SQL Consulting
- Edited by John Sansom Friday, March 7, 2014 7:45 AM
- Proposed as answer by Jayakumaur (JK) Friday, March 7, 2014 7:46 AM
- Marked as answer by Fanny Liu Monday, March 17, 2014 2:13 AM
Friday, March 7, 2014 7:40 AM
All replies
-
For a very comprehensive and Free guide to SQL Server statistics, see the Whitepaper:
Statistics Used by the Query Optimizer
With regard to your specific questions:
- Yes. What you are referring to are column statistics.
- Yes. The query optimizer determines if statistics would be "helpful" for a given query and if so creates them. Therefore as your queries/workload profile changes, so to can the column statistics that are created.
Again, the whitepaper contains a more detailed explanation.
John Sansom | SQL Server MCM
Blog | Twitter | LinkedIn | SQL Consulting
- Edited by John Sansom Friday, March 7, 2014 7:45 AM
- Proposed as answer by Jayakumaur (JK) Friday, March 7, 2014 7:46 AM
- Marked as answer by Fanny Liu Monday, March 17, 2014 2:13 AM
Friday, March 7, 2014 7:40 AM -
is there any possibility,that sqlserver will create same statistics with diffrent name again ?
It will only auto-create particular statistics once. This could be a duplicate for manually created statistics.
Gert-Jan
Friday, March 7, 2014 1:48 PM -
Even if i have created manual statistics while making database. That is at early stage, before any query execution.
yorus sincerley
Wednesday, March 12, 2014 8:55 AM -
It's quite easy to test. Apparently on SQL Server 2008 (where I run the code below), it seems to be quite intelligent, and only auto-create the statistics when there are no suitable statistics already.
I say: just test it for yourself.
create table test (id int identity primary key, col2 int) create table test2 (id int identity primary key, col2 int) create table test3 (id int identity primary key, col2 int, col3 int) create statistics st_test on test(col2) create statistics st_test3 on test3(col2,col3) select id from test where col2=3 select id from test2 where col2=3 select id from test3 where col2=3 select id from test3 where col3=4 go exec sp_helpstats test exec sp_helpstats test2 exec sp_helpstats test3 go drop table test3 drop table test2 drop table test
statistics_name statistics_keys -------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- st_test col2 statistics_name statistics_keys -------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- _WA_Sys_00000002_5D95E53A col2 statistics_name statistics_keys -------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- _WA_Sys_00000003_6166761E col3 st_test3 col2, col3
Gert-Jan
Wednesday, March 12, 2014 11:09 AM