Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Introducing Microsoft SQL Server 2019

You're reading from  Introducing Microsoft SQL Server 2019

Product type Book
Published in Apr 2020
Publisher Packt
ISBN-13 9781838826215
Pages 488 pages
Edition 1st Edition
Languages
Authors (8):
Kellyn Gorman Kellyn Gorman
Profile icon Kellyn Gorman
Allan Hirt Allan Hirt
Profile icon Allan Hirt
Dave Noderer Dave Noderer
Profile icon Dave Noderer
Mitchell Pearson Mitchell Pearson
Profile icon Mitchell Pearson
James Rowland-Jones James Rowland-Jones
Profile icon James Rowland-Jones
Dustin Ryan Dustin Ryan
Profile icon Dustin Ryan
Arun Sirpal Arun Sirpal
Profile icon Arun Sirpal
Buck Woody Buck Woody
Profile icon Buck Woody
View More author details
Toc

Table of Contents (15) Chapters close

Preface 1. Optimizing for performance, scalability and real‑time insights 2. Enterprise Security 3. High Availability and Disaster Recovery 4. Hybrid Features – SQL Server and Microsoft Azure 5. SQL Server 2019 on Linux 6. SQL Server 2019 in Containers and Kubernetes 7. Data Virtualization 8. Machine Learning Services Extensibility Framework 9. SQL Server 2019 Big Data Clusters 10. Enhancing the Developer Experience 11. Data Warehousing 12. Analysis Services 13. Power BI Report Server 14. Modernization to the Azure Cloud

Columnstore stats in DBCC CLONEDATABASE

DBCC CLONEDATABASE creates a clone of the database that contains a copy of the schema and statistics for troubleshooting and diagnostic purposes. More specifically, with DBCC CLONEDATABASE, you have a lightweight, minimally invasive way to investigate performance issues related to the query optimizer. In SQL Server 2019, we now extend the capabilities of DBCC CLONEDATABASE by adding support for columnstore statistics.

Columnstore statistics support

In SQL Server 2019, support has been added for columnstore statistics. Before SQL Server 2019, manual steps were required to capture these statistics (refer to the following link). We now automatically capture stats blobs, and therefore, these manual steps are no longer required:

https://techcommunity.microsoft.com/t5/SQL-Server/Considerations-when-tuning-your-queries-with-columnstore-indexes/ba-p/385294.

DBCC CLONEDATABASE validations

DBCC CLONEDATABASE performs the following validation checks. If any of these checks fail, the operation will fail, and a copy of the database will not be provided.

  • The source database must be a user database.
  • The source database must be online or readable.
  • The clone database name must not already exist.
  • The command must not be part of a user transaction.

Understanding DBCC CLONEDATABASE syntax

DBCC CLONEDATABASE syntax with optional parameters:

DBCC CLONEDATABASE   
(  
    source_database_name, target_database_name
)
    [ WITH { [ NO_STATISTICS ] [ , NO_QUERYSTORE ] 
    [ , VERIFY_CLONEDB | SERVICEBROKER ] [ , BACKUP_CLONEDB ] } ]

The following T-SQL script will create a clone of the existing database. The statistics and Query Store data are included automatically.

DBCC CLONEDATABASE ('Source', 'Destination');

The following messages are provided upon completion:

Figure 1.25: Cloned database output
Figure 1.24: Cloned database output

To exclude statistics, you rewrite the code to include WITH NO_STATISTICS:

DBCC CLONEDATABASE ('Source', 'Destination_NoStats') 
WITH NO_STATISTICS;

To exclude statistics and Query Store data, execute the following code:

DBCC CLONEDATABASE ('Source', 'Destination_NoStats_NoQueryStore') 
  WITH NO_STATISTICS, NO_QUERYSTORE;

Making the clone database production-ready

Thus far, the database clones provisioned are purely for diagnostic purposes. The option VERIFY_CLONEDB is required if you want to use the cloned database for production use. VERIFY_CLONEDB will verify the consistency of the new database.

For example:

DBCC CLONEDATABASE ('Source', 'Destination_ProdReady') 
  WITH VERIFY_CLONEDB;

The output is as follows:

Figure 1.26: Verifying the cloned database
Figure 1.25: Verifying the cloned database
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime