|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: 2 days ago @ 9:35 AM
Points: 109,
Visits: 266
|
|
Here is the issue:
Developers want statistics created on every column on every table in the database.
SQL version = SQL Server 2005 SP2+. database < 200GB. "Auto update" and "Auto create" stats are enabled. There are currently 11000+ user created statistics.
Here is the question: Will SQL Server ever use those statistics ?? What other SQL process besides the optimizer uses the statistics ?? Is there any way to determine statistic usage ??
I need some ammo for my argument ... sock it to me.
Enjoy "Give them the tools ... Not the keys "
|
|
|
|
|
SSCoach
         
Group: General Forum Members
Last Login: Thursday, May 16, 2013 1:46 PM
Points: 18,732,
Visits: 12,329
|
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: 2 days ago @ 9:35 AM
Points: 109,
Visits: 266
|
|
I told them there is no reason to do that for every column and every table ... but they insist. I need to come up with some good reasons not to do it.
that is why I'm asking for more ammo...
Enjoy "Give them the tools ... Not the keys "
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Thursday, May 16, 2013 7:44 AM
Points: 1,555,
Visits: 1,925
|
|
Just like indexes any additional statistics create maintenance overhead in both space used (it has to store it someplace) and the duration of maintenance (it does take time to update them.) If auto update stats is on then that can lead to slowness during the day while SQL updates stats that it may not even be using. If it's not on that means time needs to be put into developing a maintenance plan that will do that and a longer duration for maintenance. I would have to defer to someone with more knowledge on this point but I would also think that with additional statistics to consider when calculating the query plan compiling plans can take longer.
There are also columns where creating stats will never have the opportunity to be used. If SQL isn't using that column to search then the stats won't be used. And if a column is frequently being used but isn't indexed and doesn't have a manually created stat on it then SQL can create one if auto create stats is on. We have created stats in our DB but for the most part we rely on SQL to do that when needed.
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Tuesday, March 26, 2013 8:41 AM
Points: 2,562,
Visits: 3,451
|
|
|
|
|
|
SSCoach
         
Group: General Forum Members
Last Login: Thursday, May 16, 2013 1:46 PM
Points: 18,732,
Visits: 12,329
|
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Wednesday, April 24, 2013 3:17 PM
Points: 6,731,
Visits: 12,131
|
|
Maybe this argument will help, too:
Within one query, SQL server will only use one index per table. So, if you have the following querySELECT col1, col2, col3, col4 FROM table WHERE col1='something' AND col2='something different'
and you have an index on each and every single column then the query optimizer may not consider any of those indexes, since a bookmark lookup would be required to get all values used in the SELECT clause. It might be appropriate to use a single index on col1 and col2 with col3 an col4 as included columns. SQL server will not combine various indexes for one table within one query.
Furthermore, it might even drop performance if the table in question is heavily used for updates/inserts/deletes, since each and every index would need to be changed.
Edit: Incorrect answer.
Lutz A pessimist is an optimist with experience.
How to get fast answers to your question How to post performance related questions Links for Tally Table , Cross Tabs and Dynamic Cross Tabs , Delimited Split Function
|
|
|
|
|
Right there with Babe
      
Group: General Forum Members
Last Login: Thursday, March 14, 2013 10:22 AM
Points: 750,
Visits: 2,937
|
|
I'd ask them why they want autocreate stats on if they are going to do it themselves.
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Yesterday @ 8:50 AM
Points: 3,572,
Visits: 5,106
|
|
lmu92 (3/24/2010)
Maybe this argument will help, too: Within one query, SQL server will only use one index per table. So, if you have the following query SELECT col1, col2, col3, col4 FROM table WHERE col1='something' AND col2='something different' and you have an index on each and every single column then the query optimizer may not consider any of those indexes, since a bookmark lookup would be required to get all values used in the SELECT clause. It might be appropriate to use a single index on col1 and col2 with col3 an col4 as included columns. SQL server will not combine various indexes for one table within one query. Furthermore, it might even drop performance if the table in question is heavily used for updates/inserts/deletes, since each and every index would need to be changed.
Your statement is false. The optimizer can use more than one index in a select statement on a single table. From this location in Books Online (ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/udb9/html/7c1f2130-5574-4058-bcfb-31c115e9bd00.htm)
-------------------- Do not use multiple aliases for a single table in the same query to simulate index intersection. This is no longer necessary because SQL Server automatically considers index intersection and can make use of multiple indexes on the same table in the same query. Consider the sample query:
SELECT * FROM lineitem WHERE partkey BETWEEN 17000 AND 17100 AND shipdate BETWEEN '1/1/1994' AND '1/31/1994' SQL Server can exploit indexes on both the partkey and shipdate columns, and then perform a hash match between the two subsets to obtain the index intersection. --------------------
I also note that this thread has nothing to do with indexes - it is about statistics.
Best,
Kevin G. Boles SQL Server Consultant SQL MVP 2007-2012 TheSQLGuru at GMail
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: 2 days ago @ 9:35 AM
Points: 109,
Visits: 266
|
|
Thanx to all that replied to this post ... your comments are greatly appreciated and helpfull.
Enjoy "Give them the tools ... Not the keys "
|
|
|
|