Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
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 Reliability, scalability, and security both on premises and in the cloud

Arrow left icon
Product type Paperback
Published in Apr 2020
Publisher Packt
ISBN-13 9781838826215
Length 488 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (8):
Arrow left icon
Allan Hirt Allan Hirt
Author Profile Icon Allan Hirt
Allan Hirt
Dustin Ryan Dustin Ryan
Author Profile Icon Dustin Ryan
Dustin Ryan
Mitchell Pearson Mitchell Pearson
Author Profile Icon Mitchell Pearson
Mitchell Pearson
Kellyn Gorman Kellyn Gorman
Author Profile Icon Kellyn Gorman
Kellyn Gorman
Dave Noderer Dave Noderer
Author Profile Icon Dave Noderer
Dave Noderer
Buck Woody Buck Woody
Author Profile Icon Buck Woody
Buck Woody
Arun Sirpal Arun Sirpal
Author Profile Icon Arun Sirpal
Arun Sirpal
James Rowland-Jones James Rowland-Jones
Author Profile Icon James Rowland-Jones
James Rowland-Jones
+4 more Show less
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Preface 1. Optimizing for performance, scalability and real‑time insights 2. Enterprise Security FREE CHAPTER 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 $19.99/month. Cancel anytime
Banner background image