SQL Statistics

What command should I issue to update the Statistics on SQL tables ? Can it refresh automatically or I need to update it periodically ? What's the impact if statistics is not up-to-date ?

Tks
AXISHKAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PortletPaulfreelancerCommented:
0
PortletPaulfreelancerCommented:
I'd like to suggest you look at this you may find it useful:

SQL Server Backup, Integrity Check, and Index and Statistics Maintenance

The SQL Server Maintenance Solution comprises scripts for running backups, integrity checks, and index and statistics maintenance on all editions of Microsoft SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012, and SQL Server 2014. The solution is based on stored procedures, the sqlcmd utility, and SQL Server Agent jobs. I designed the solution for the most mission-critical environments, and it is used in many organizations around the world. Numerous SQL Server community experts recommend the SQL Server Maintenance Solution, which has been a Gold winner in the 2013, 2012, 2011, and 2010 SQL Server Magazine Awards. The SQL Server Maintenance Solution is free.
Ola Hallengren
http://ola.hallengren.com/

This conference video is a useful introduction as Ola explains his approach and answers questions: recommended video
0
Scott PletcherSenior DBACommented:
>> What command should I issue to update the Statistics on SQL tables ? <<
UPDATE STATISTICS


>> Can it refresh automatically or I need to update it periodically ? What's the impact if statistics is not up-to-date ? <<
Those are extraordinarily broad and general questions that can't be answered generally.  The correct answer can only be based on a specific case.  That is, each table's stats could have different answers for that q, depending on the specific usage of that specific table.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

AXISHKAuthor Commented:
what's the impact if the statistic is not up to date ?

Tks
0
PortletPaulfreelancerCommented:
Good statistics allow the optimizer to accurately assess the cost of different query plans and then choose a high-quality plan.
Statistics Used by the Query Optimizer in Microsoft SQL Server 2008

Every Index has associated statistics, but statistics also exist for un-indexed columns (or sets of columns). If the statistics are "stale" (or "not fresh") then there is an increased chance of sub-optimal query plans being chosen.

In reality you need both fresh statistics and "tidy" indexes, but there are many factors to consider. I thoroughly recommend that video of Ola Hallengren - even if you are not using his scripts there are many tips and hints about stats and indexes in it.

There is also a myth about statistics I mind amusing;
Myth: You need to refresh statistics after rebuilding an Index
This isn't true.
If you do rebuild an index the relevant statistics are refreshed at the same time.

So, the 2 topics, Statistics and Indexes, are related but not the same.

btw: Scott Pletcher knows a big bundle more about SQL Server indexes than I do
0
Scott PletcherSenior DBACommented:
>>
There is also a myth about statistics I mind amusing;
 Myth: You need to refresh statistics after rebuilding an Index
This isn't true.
<<

Quite right!  In fact, you'd make SQL's stats less effective if you refreshed them after rebuilding an index.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AXISHKAuthor Commented:
Tks
0
PortletPaulfreelancerCommented:
I do the work, Scott gets the points?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.