Updated ADR notebooks

This commit is contained in:
pmasl
2019-11-02 17:06:18 -07:00
parent 3416e61f71
commit 47d370c63e
2 changed files with 48 additions and 30 deletions
@@ -36,8 +36,6 @@
"\r\n",
"The database assumes a path for a standard SQL Server Windows installation.\r\n",
"\r\n",
"**Note**: Change restore path as needed\r\n",
"\r\n",
"**Note**: *For Linux installations the default path to use is /var/opt/mssql*"
],
"metadata": {
@@ -52,12 +50,20 @@
"IF EXISTS (SELECT [database_id] FROM sys.databases WHERE [name] = 'WideWorldImportersDW')\r\n",
"ALTER DATABASE [WideWorldImportersDW] SET SINGLE_USER WITH ROLLBACK IMMEDIATE\r\n",
"GO\r\n",
"RESTORE DATABASE [WideWorldImportersDW] FROM DISK = N'E:\\SampleDBs\\WideWorldImportersDW\\WideWorldImportersDW-Full.bak' WITH FILE = 1,\r\n",
"\tMOVE N'WWI_Primary' TO N'D:\\Program Files\\Microsoft SQL Server\\MSSQL15.SQL2019\\MSSQL\\DATA\\WideWorldImportersDW.mdf', \r\n",
"\tMOVE N'WWI_UserData' TO N'D:\\Program Files\\Microsoft SQL Server\\MSSQL15.SQL2019\\MSSQL\\DATA\\WideWorldImportersDW_UserData.ndf', \r\n",
"\tMOVE N'WWI_Log' TO N'D:\\Program Files\\Microsoft SQL Server\\MSSQL15.SQL2019\\MSSQL\\DATA\\WideWorldImportersDW.ldf', \r\n",
"\tMOVE N'WWIDW_InMemory_Data_1' TO N'D:\\Program Files\\Microsoft SQL Server\\MSSQL15.SQL2019\\MSSQL\\DATA\\WideWorldImportersDW_InMemory_Data_1', NOUNLOAD, REPLACE, STATS = 10\r\n",
"ALTER DATABASE [WideWorldImportersDW] SET MULTI_USER\r\n",
"\r\n",
"DECLARE @datafilepath VARCHAR(8000) = CAST(SERVERPROPERTY('InstanceDefaultDataPath') AS VARCHAR(4000)) + 'WideWorldImportersDW.mdf'\r\n",
"DECLARE @logfilepath VARCHAR(8000) = CAST(SERVERPROPERTY('InstanceDefaultLogPath') AS VARCHAR(4000)) + 'WideWorldImportersDW.ldf'\r\n",
"DECLARE @inmemfilepath VARCHAR(8000) = CAST(SERVERPROPERTY('InstanceDefaultLogPath') AS VARCHAR(4000)) + 'WideWorldImportersDW_InMemory_Data_1'\r\n",
"DECLARE @secondaryfilepath VARCHAR(8000) = CAST(SERVERPROPERTY('InstanceDefaultLogPath') AS VARCHAR(4000))+ 'WideWorldImportersDW_2.ndf'\r\n",
"\r\n",
"-- Change @backupfile file path as needed\r\n",
"DECLARE @backupfile VARCHAR(8000) = 'E:\\SampleDBs\\WideWorldImportersDW-Full.bak'\r\n",
"RESTORE DATABASE WideWorldImportersDW\r\n",
"FROM DISK = @backupfile \r\n",
"WITH MOVE 'WWI_Primary' TO @datafilepath,\r\n",
" MOVE 'WWI_UserData' TO @secondaryfilepath,\r\n",
" MOVE 'WWIDW_InMemory_Data_1' TO @inmemfilepath,\r\n",
" MOVE 'WWI_Log' TO @logfilepath, NOUNLOAD, REPLACE, STATS = 10\r\n",
"GO\r\n",
"\r\n",
"USE [master]\r\n",
@@ -689,7 +695,6 @@
},
{
"output_type": "execute_result",
"metadata": {},
"execution_count": 38,
"data": {
"application/vnd.dataresource+json": {
@@ -723,7 +728,8 @@
]
},
"text/html": "<table><tr><th>database_id</th><th>total_log_size_in_bytes</th><th>used_log_space_in_bytes</th><th>used_log_space_in_percent</th><th>log_space_in_bytes_since_last_backup</th></tr><tr><td>8</td><td>4294959104</td><td>2810818560</td><td>65.4446</td><td>825794560</td></tr></table>"
}
},
"metadata": {}
}
],
"execution_count": 38
@@ -773,7 +779,6 @@
},
{
"output_type": "execute_result",
"metadata": {},
"execution_count": 39,
"data": {
"application/vnd.dataresource+json": {
@@ -807,7 +812,8 @@
]
},
"text/html": "<table><tr><th>database_id</th><th>total_log_size_in_bytes</th><th>used_log_space_in_bytes</th><th>used_log_space_in_percent</th><th>log_space_in_bytes_since_last_backup</th></tr><tr><td>8</td><td>4294959104</td><td>2810855424</td><td>65.44545</td><td>825262080</td></tr></table>"
}
},
"metadata": {}
}
],
"execution_count": 39
@@ -894,7 +900,6 @@
},
{
"output_type": "execute_result",
"metadata": {},
"execution_count": 41,
"data": {
"application/vnd.dataresource+json": {
@@ -928,7 +933,8 @@
]
},
"text/html": "<table><tr><th>database_id</th><th>total_log_size_in_bytes</th><th>used_log_space_in_bytes</th><th>used_log_space_in_percent</th><th>log_space_in_bytes_since_last_backup</th></tr><tr><td>8</td><td>4294959104</td><td>981958656</td><td>22.86305</td><td>783413248</td></tr></table>"
}
},
"metadata": {}
}
],
"execution_count": 41
@@ -938,7 +944,7 @@
"source": [
"## Step 7: Turn on Accelerated Database Recovery\r\n",
"\r\n",
"**Note**: Change the new database file path as needed. Alternatively, just execute the last `ALTER DATABASE` without the `( PERSISTENT_VERSION_STORE_FILEGROUP = [PVS])` statement to enable ADR in the existing database file in the PRIMARY filegroup."
"**Note**: If you prefer to enable ADR in the existing database file in the PRIMARY filegroup, just execute the last `ALTER DATABASE` without the `( PERSISTENT_VERSION_STORE_FILEGROUP = [PVS])` statement."
],
"metadata": {
"azdata_cell_guid": "6dd6df07-c8a8-4af5-a37c-e76387891562"
@@ -952,7 +958,10 @@
"-- Add a new filegroup specific for the Persistent Version Store (optional)\r\n",
"ALTER DATABASE [WideWorldImportersDW] ADD FILEGROUP [PVS]\r\n",
"GO\r\n",
"ALTER DATABASE [WideWorldImportersDW] ADD FILE ( NAME = N'ADR', FILENAME = N'D:\\Program Files\\Microsoft SQL Server\\MSSQL15.SQL2019\\MSSQL\\DATA\\ADR.ndf' , SIZE = 1GB , FILEGROWTH = 65536KB ) TO FILEGROUP [PVS]\r\n",
"\r\n",
"DECLARE @adrdatafilepath VARCHAR(8000) = CAST(SERVERPROPERTY('InstanceDefaultDataPath') AS VARCHAR(4000)) + 'ADR.mdf'\r\n",
"DECLARE @sqlcmd VARCHAR(8000) = 'ALTER DATABASE [WideWorldImportersDW] ADD FILE ( NAME = N''ADR'', FILENAME = ''' + @adrdatafilepath + ''', SIZE = 1GB , FILEGROWTH = 65536KB ) TO FILEGROUP [PVS]'\r\n",
"EXEC (@sqlcmd)\r\n",
"GO\r\n",
"\r\n",
"-- Enable ADR\r\n",
@@ -1080,7 +1089,6 @@
},
{
"output_type": "execute_result",
"metadata": {},
"execution_count": 44,
"data": {
"application/vnd.dataresource+json": {
@@ -1114,7 +1122,8 @@
]
},
"text/html": "<table><tr><th>database_id</th><th>total_log_size_in_bytes</th><th>used_log_space_in_bytes</th><th>used_log_space_in_percent</th><th>log_space_in_bytes_since_last_backup</th></tr><tr><td>8</td><td>4294959104</td><td>2085478400</td><td>48.55642</td><td>1794609152</td></tr></table>"
}
},
"metadata": {}
},
{
"output_type": "display_data",
@@ -1139,7 +1148,6 @@
},
{
"output_type": "execute_result",
"metadata": {},
"execution_count": 44,
"data": {
"application/vnd.dataresource+json": {
@@ -1173,7 +1181,8 @@
]
},
"text/html": "<table><tr><th>database_id</th><th>total_log_size_in_bytes</th><th>used_log_space_in_bytes</th><th>used_log_space_in_percent</th><th>log_space_in_bytes_since_last_backup</th></tr><tr><td>8</td><td>4294959104</td><td>1299976192</td><td>30.26749</td><td>1011310592</td></tr></table>"
}
},
"metadata": {}
}
],
"execution_count": 44
@@ -37,8 +37,6 @@
"\r\n",
"Depending on the speed of your server, enlarging the database and data could take several minutes.\r\n",
"\r\n",
"**Note**: Change restore path as needed\r\n",
"\r\n",
"**Note**: *For Linux installations the default path to use is /var/opt/mssql*"
],
"metadata": {
@@ -53,12 +51,20 @@
"IF EXISTS (SELECT [database_id] FROM sys.databases WHERE [name] = 'WideWorldImportersDW')\r\n",
"ALTER DATABASE [WideWorldImportersDW] SET SINGLE_USER WITH ROLLBACK IMMEDIATE\r\n",
"GO\r\n",
"RESTORE DATABASE [WideWorldImportersDW] FROM DISK = N'E:\\SampleDBs\\WideWorldImportersDW\\WideWorldImportersDW-Full.bak' WITH FILE = 1,\r\n",
"\tMOVE N'WWI_Primary' TO N'D:\\Program Files\\Microsoft SQL Server\\MSSQL15.SQL2019\\MSSQL\\DATA\\WideWorldImportersDW.mdf', \r\n",
"\tMOVE N'WWI_UserData' TO N'D:\\Program Files\\Microsoft SQL Server\\MSSQL15.SQL2019\\MSSQL\\DATA\\WideWorldImportersDW_UserData.ndf', \r\n",
"\tMOVE N'WWI_Log' TO N'D:\\Program Files\\Microsoft SQL Server\\MSSQL15.SQL2019\\MSSQL\\DATA\\WideWorldImportersDW.ldf', \r\n",
"\tMOVE N'WWIDW_InMemory_Data_1' TO N'D:\\Program Files\\Microsoft SQL Server\\MSSQL15.SQL2019\\MSSQL\\DATA\\WideWorldImportersDW_InMemory_Data_1', NOUNLOAD, REPLACE, STATS = 10\r\n",
"ALTER DATABASE [WideWorldImportersDW] SET MULTI_USER\r\n",
"\r\n",
"DECLARE @datafilepath VARCHAR(8000) = CAST(SERVERPROPERTY('InstanceDefaultDataPath') AS VARCHAR(4000)) + 'WideWorldImportersDW.mdf'\r\n",
"DECLARE @logfilepath VARCHAR(8000) = CAST(SERVERPROPERTY('InstanceDefaultLogPath') AS VARCHAR(4000)) + 'WideWorldImportersDW.ldf'\r\n",
"DECLARE @inmemfilepath VARCHAR(8000) = CAST(SERVERPROPERTY('InstanceDefaultLogPath') AS VARCHAR(4000)) + 'WideWorldImportersDW_InMemory_Data_1'\r\n",
"DECLARE @secondaryfilepath VARCHAR(8000) = CAST(SERVERPROPERTY('InstanceDefaultLogPath') AS VARCHAR(4000))+ 'WideWorldImportersDW_2.ndf'\r\n",
"\r\n",
"-- Change @backupfile file path as needed\r\n",
"DECLARE @backupfile VARCHAR(8000) = 'E:\\SampleDBs\\WideWorldImportersDW-Full.bak'\r\n",
"RESTORE DATABASE WideWorldImportersDW\r\n",
"FROM DISK = @backupfile \r\n",
"WITH MOVE 'WWI_Primary' TO @datafilepath,\r\n",
" MOVE 'WWI_UserData' TO @secondaryfilepath,\r\n",
" MOVE 'WWIDW_InMemory_Data_1' TO @inmemfilepath,\r\n",
" MOVE 'WWI_Log' TO @logfilepath, NOUNLOAD, REPLACE, STATS = 10\r\n",
"GO\r\n",
"\r\n",
"USE [master]\r\n",
@@ -696,7 +702,7 @@
"\r\n",
"Turn on Accelerated Database Recovery and try to delete the rows again.\r\n",
"\r\n",
"**Note**: Change the new database file path as needed. Alternatively, just execute the last `ALTER DATABASE` without the `( PERSISTENT_VERSION_STORE_FILEGROUP = [PVS])` statement to enable ADR in the existing database file in the PRIMARY filegroup.\r\n",
"**Note**: If you prefer to enable ADR in the existing database file in the PRIMARY filegroup, just execute the last `ALTER DATABASE` without the `( PERSISTENT_VERSION_STORE_FILEGROUP = [PVS])` statement.\r\n",
"\r\n",
"You may first see a connection error first since you shutdown SQL Server in the previous step but the cell should retry the connection and run the T-SQL statements."
],
@@ -712,7 +718,10 @@
"-- Add a new filegroup specific for the Persistent Version Store (optional)\r\n",
"ALTER DATABASE [WideWorldImportersDW] ADD FILEGROUP [PVS]\r\n",
"GO\r\n",
"ALTER DATABASE [WideWorldImportersDW] ADD FILE ( NAME = N'ADR', FILENAME = N'D:\\Program Files\\Microsoft SQL Server\\MSSQL15.SQL2019\\MSSQL\\DATA\\ADR.ndf' , SIZE = 1GB , FILEGROWTH = 65536KB ) TO FILEGROUP [PVS]\r\n",
"\r\n",
"DECLARE @adrdatafilepath VARCHAR(8000) = CAST(SERVERPROPERTY('InstanceDefaultDataPath') AS VARCHAR(4000)) + 'ADR.mdf'\r\n",
"DECLARE @sqlcmd VARCHAR(8000) = 'ALTER DATABASE [WideWorldImportersDW] ADD FILE ( NAME = N''ADR'', FILENAME = ''' + @adrdatafilepath + ''', SIZE = 1GB , FILEGROWTH = 65536KB ) TO FILEGROUP [PVS]'\r\n",
"EXEC (@sqlcmd)\r\n",
"GO\r\n",
"\r\n",
"-- Enable ADR\r\n",