This article is half-done without your Comment! *** Please share your thoughts via Comment ***
SQL Server 2014 introduced DBCC CLONEDATABASE for creating a blank database with only Schema and Statistics.
SQL Server 2016 added support of the Query Store in DBCC CLONEDATABASE.
This feature is very helpful in certain conditions.
For example, Your production database size is around 800 GB, and You faced some performance related issues because the problem of outdated Statistics or Indexes issue.
Now the situation is, you can do a test and trial in your Production Database, so DBA takes a copy of Production Database and restore it in different server for further investigation.
Do you think, this is the only one solution because Its require additional time and infrastructure.
In this kind of situation, you can use the DBCC CLONEDATABASE feature of SQL Server 2014.
It creates a blank database copy with the only Schema, Statistics and Query Store information. It is not copying the data, so it does not require any additional space.
You can find the same statistical information in the new clone database which generates the same execution plan for your investigation.
A Query Execution Plan is prepared to base on Database Statistics so If Database Statistics are same then you check your query execution plan without data.
Once you are finished with your task with Clone Database, you can delete it.
How internally SQL Server creates a Clone Database?
It validates the source database and acquires the shared lock on the source database
It creates a snapshot of the source database (Include only: Schema, Statistics, Query Store)
Create Clone Database and acquires an exclusive lock on it
Copy the metadata, schema, statistics, query store information from the source database to clone database
Release all locks from Clone Database
How to create a Clone Database?
Use DBCC CLONEDATABASE command to create a Clone Database.
1 |
DBCC CLONEDATABASE (MyDatabase,MyDatabase_Clone); |
Leave a Reply