Just wondering are statistics kept in the database but not in the memory? If I backup/restore the database from a prod server to a development server, would it keep the same statistics so that execution plans won't be much different if I do it on the development server?
Sql-server – Are SQL Server statistics stored in database or buffer pool
execution-plansql serverstatistics
Related Question
- Sql-server – How Can the Same Query in Two Nearly Identical Instances Generate Two Different Execution Plans
- Sql-server – Does restoring database clear buffer cache and stored proc cache
- SQL Server Statistics – How to Fix Incorrect Estimates
- Sql-server – SQL Server recreating plans each day
- SQL Server – Execution Plans Behavior After a Restart
- SQL Server – Will a VM Backup Work for Database Restoration?
Best Answer
The buffer pool is a cache of the database. There is never an 'or', things that are in the buffer pool are also in the database, always. And anything read from the database must be, even temporarily, present in the buffer pool.
As for the question: statistics are in the database so a backup/restore will preserve the statistics.
Note though that preserving statistics is not a guarantee to plan reproducibility. Other factors influence plan generation, like number of CPUs and amount of RAM.