Detaching and Attaching Databases - UPDATE STATISTICS

Hi experts:

i am reading about UPDATE STATISTICS Detaching and Attaching Databases but i do not understand this:
Point out that an option exists that performs an UPDATE STATISTICS on table and index statistics before detaching. This might be a good option if the database is attached in a read-only environment. Typically, however, it is not a good choice if the database should just be moved to a new location.
enrique_aeoAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

DBAduck - Ben MillerPrincipal ConsultantCommented:
All this means is that if you intend on attaching the database to a read only state on another server,  that you can update statistics before you detach because you won't be able to update them in the read only environment.

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
arnoldCommented:
Do you normally detach/attach databases, if not, this does not apply to you.

The issue deals with building/updating the statistics while the database is in writeable mode.  The statistics are used in the execution plan such that it helps improve query performance.
If you do not run update statistics prior to detaching and then attach the database in read-only mode, the execution of queries might not be as optimal as it would be if update statistics were ran prior to detaching.

If the transition is to a writeable location, no need since the new location can and will perform the update statistics on database as needed.
enrique_aeoAuthor Commented:
Update statistics for all tables in a DB can be slow? based on their experience can comment me?
arnoldCommented:
What are you asking here? Config of db has option synchronous/asynchronous statistics update.
It should be updated and often tasks rung on sat/sun off peak ........
Rebuilding and reorganizing indexes .........
DBAduck - Ben MillerPrincipal ConsultantCommented:
You can simply run sp_updatestats on the database before you detach.  If you were wanting to do more you can use the UPDATE STATISTICS statement but this is more than you should need if you were going to move a database to a readonly environment.
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.