mirror of
https://github.com/Microsoft/sql-server-samples.git
synced 2025-12-08 14:58:54 +00:00
resolve conflicts
This commit is contained in:
+2
-2
@@ -3,7 +3,7 @@
|
||||
-- bigger - so you can see more impactful
|
||||
-- Intelligent QP demonstrations (aka.ms/iqp)
|
||||
--
|
||||
-- Script last updated 10/02/2018
|
||||
-- Script last updated 05/03/2019
|
||||
--
|
||||
-- Database backup source: aka.ms/wwibak
|
||||
--
|
||||
@@ -100,4 +100,4 @@ GO
|
||||
|
||||
UPDATE Fact.OrderHistoryExtended
|
||||
SET [WWI Order ID] = [Order Key];
|
||||
GO
|
||||
GO
|
||||
+11
-1
@@ -9,7 +9,17 @@
|
||||
|
||||
-- Email IntelligentQP@microsoft.com for questions\feedback
|
||||
-- ******************************************************** --
|
||||
USE WideWorldImportersDW;
|
||||
|
||||
USE [master];
|
||||
GO
|
||||
|
||||
ALTER DATABASE [WideWorldImportersDW] SET COMPATIBILITY_LEVEL = 150;
|
||||
GO
|
||||
|
||||
ALTER DATABASE SCOPED CONFIGURATION CLEAR PROCEDURE_CACHE;
|
||||
GO
|
||||
|
||||
USE [WideWorldImportersDW];
|
||||
GO
|
||||
|
||||
-- Compare execution time and distinct counts
|
||||
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
-- ******************************************************** --
|
||||
-- Batch mode Adaptive Join
|
||||
|
||||
-- See https://aka.ms/IQP for more background
|
||||
|
||||
-- Demo scripts: https://aka.ms/IQPDemos
|
||||
|
||||
-- This demo is on SQL Server 2017 and Azure SQL DB
|
||||
|
||||
-- Email IntelligentQP@microsoft.com for questions\feedback
|
||||
-- ******************************************************** --
|
||||
|
||||
USE [master];
|
||||
GO
|
||||
|
||||
ALTER DATABASE [WideWorldImportersDW] SET COMPATIBILITY_LEVEL = 140;
|
||||
GO
|
||||
|
||||
ALTER DATABASE SCOPED CONFIGURATION CLEAR PROCEDURE_CACHE;
|
||||
GO
|
||||
|
||||
USE [WideWorldImportersDW];
|
||||
GO
|
||||
|
||||
-- Show with Live Query Stats
|
||||
SELECT [fo].[Order Key], [si].[Lead Time Days], [fo].[Quantity]
|
||||
FROM [Fact].[Order] AS [fo]
|
||||
INNER JOIN [Dimension].[Stock Item] AS [si]
|
||||
ON [fo].[Stock Item Key] = [si].[Stock Item Key]
|
||||
WHERE [fo].[Quantity] = 360;
|
||||
GO
|
||||
|
||||
-- Inserting quantity row that doesn't exist in the table yet
|
||||
DELETE [Fact].[Order]
|
||||
WHERE Quantity = 361;
|
||||
|
||||
INSERT [Fact].[Order]
|
||||
([City Key], [Customer Key], [Stock Item Key], [Order Date Key], [Picked Date Key], [Salesperson Key], [Picker Key], [WWI Order ID], [WWI Backorder ID], Description, Package, Quantity, [Unit Price], [Tax Rate], [Total Excluding Tax], [Tax Amount], [Total Including Tax], [Lineage Key])
|
||||
SELECT TOP 5 [City Key], [Customer Key], [Stock Item Key],
|
||||
[Order Date Key], [Picked Date Key], [Salesperson Key],
|
||||
[Picker Key], [WWI Order ID], [WWI Backorder ID],
|
||||
Description, Package, 361, [Unit Price], [Tax Rate],
|
||||
[Total Excluding Tax], [Tax Amount], [Total Including Tax],
|
||||
[Lineage Key]
|
||||
FROM [Fact].[Order];
|
||||
GO
|
||||
|
||||
-- Show with Live Query Stats
|
||||
SELECT [fo].[Order Key], [si].[Lead Time Days], [fo].[Quantity]
|
||||
FROM [Fact].[Order] AS [fo]
|
||||
INNER JOIN [Dimension].[Stock Item] AS [si]
|
||||
ON [fo].[Stock Item Key] = [si].[Stock Item Key]
|
||||
WHERE [fo].[Quantity] = 361;
|
||||
GO
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
-- ******************************************************** --
|
||||
-- Batch mode Memory Grant Feedback
|
||||
|
||||
-- See https://aka.ms/IQP for more background
|
||||
|
||||
-- Demo scripts: https://aka.ms/IQPDemos
|
||||
|
||||
-- This demo is on SQL Server 2017 and Azure SQL DB
|
||||
|
||||
-- Email IntelligentQP@microsoft.com for questions\feedback
|
||||
-- ******************************************************** --
|
||||
|
||||
USE [master];
|
||||
GO
|
||||
|
||||
ALTER DATABASE [WideWorldImportersDW] SET COMPATIBILITY_LEVEL = 140;
|
||||
GO
|
||||
|
||||
ALTER DATABASE SCOPED CONFIGURATION CLEAR PROCEDURE_CACHE;
|
||||
GO
|
||||
|
||||
USE [WideWorldImportersDW];
|
||||
GO
|
||||
|
||||
-- Intentionally forcing a row underestimate
|
||||
CREATE OR ALTER PROCEDURE [FactOrderByLineageKey]
|
||||
@LineageKey INT
|
||||
AS
|
||||
SELECT [fo].[Order Key], [fo].[Description]
|
||||
FROM [Fact].[Order] AS [fo]
|
||||
INNER HASH JOIN [Dimension].[Stock Item] AS [si]
|
||||
ON [fo].[Stock Item Key] = [si].[Stock Item Key]
|
||||
WHERE [fo].[Lineage Key] = @LineageKey
|
||||
AND [si].[Lead Time Days] > 0
|
||||
ORDER BY [fo].[Stock Item Key], [fo].[Order Date Key] DESC
|
||||
OPTION (MAXDOP 1);
|
||||
GO
|
||||
|
||||
-- Compiled and executed using a lineage key that doesn't have rows
|
||||
EXEC [FactOrderByLineageKey] 8;
|
||||
GO
|
||||
|
||||
-- Execute this query a few times - each time looking at
|
||||
-- the plan to see impact on spills, memory grant size, and run time
|
||||
EXEC [FactOrderByLineageKey] 9;
|
||||
GO
|
||||
+6
@@ -10,12 +10,18 @@
|
||||
-- Email IntelligentQP@microsoft.com for questions\feedback
|
||||
-- ******************************************************** --
|
||||
|
||||
USE [master];
|
||||
GO
|
||||
|
||||
ALTER DATABASE [WideWorldImportersDW] SET COMPATIBILITY_LEVEL = 150;
|
||||
GO
|
||||
|
||||
ALTER DATABASE SCOPED CONFIGURATION CLEAR PROCEDURE_CACHE;
|
||||
GO
|
||||
|
||||
USE [WideWorldImportersDW];
|
||||
GO
|
||||
|
||||
-- Row mode due to hint
|
||||
SELECT [Tax Rate],
|
||||
[Lineage Key],
|
||||
|
||||
+173
@@ -0,0 +1,173 @@
|
||||
-- ******************************************************** --
|
||||
-- Interleaved Execution
|
||||
|
||||
-- See https://aka.ms/IQP for more background
|
||||
|
||||
-- Demo scripts: https://aka.ms/IQPDemos
|
||||
|
||||
-- This demo is on SQL Server 2017 and Azure SQL DB
|
||||
|
||||
-- Email IntelligentQP@microsoft.com for questions\feedback
|
||||
-- ******************************************************** --
|
||||
|
||||
/*
|
||||
Create MSTVF
|
||||
*/
|
||||
|
||||
USE [WideWorldImportersDW];
|
||||
GO
|
||||
|
||||
CREATE FUNCTION [Fact].[WhatIfOutlierEventQuantity](@event VARCHAR(15), @beginOrderDateKey DATE, @endOrderDateKey DATE)
|
||||
RETURNS @OutlierEventQuantity TABLE (
|
||||
[Order Key] [bigint],
|
||||
[City Key] [int] NOT NULL,
|
||||
[Customer Key] [int] NOT NULL,
|
||||
[Stock Item Key] [int] NOT NULL,
|
||||
[Order Date Key] [date] NOT NULL,
|
||||
[Picked Date Key] [date] NULL,
|
||||
[Salesperson Key] [int] NOT NULL,
|
||||
[Picker Key] [int] NULL,
|
||||
[OutlierEventQuantity] [int] NOT NULL)
|
||||
AS
|
||||
BEGIN
|
||||
|
||||
-- Valid @event values
|
||||
-- 'Mild Recession'
|
||||
-- 'Hurricane - South Atlantic'
|
||||
-- 'Hurricane - East South Central'
|
||||
-- 'Hurricane - West South Central'
|
||||
IF @event = 'Mild Recession'
|
||||
INSERT @OutlierEventQuantity
|
||||
SELECT [o].[Order Key], [o].[City Key], [o].[Customer Key],
|
||||
[o].[Stock Item Key], [o].[Order Date Key], [o].[Picked Date Key],
|
||||
[o].[Salesperson Key], [o].[Picker Key],
|
||||
CASE
|
||||
WHEN [o].[Quantity] > 2 THEN [o].[Quantity] * .5
|
||||
ELSE [o].[Quantity]
|
||||
END
|
||||
FROM [Fact].[Order] AS [o]
|
||||
INNER JOIN [Dimension].[City] AS [c]
|
||||
ON [c].[City Key] = [o].[City Key]
|
||||
|
||||
IF @event = 'Hurricane - South Atlantic'
|
||||
INSERT @OutlierEventQuantity
|
||||
SELECT [o].[Order Key], [o].[City Key], [o].[Customer Key],
|
||||
[o].[Stock Item Key], [o].[Order Date Key], [o].[Picked Date Key],
|
||||
[o].[Salesperson Key], [o].[Picker Key],
|
||||
CASE
|
||||
WHEN [o].[Quantity] > 10 THEN [o].[Quantity] * .5
|
||||
ELSE [o].[Quantity]
|
||||
END
|
||||
FROM [Fact].[Order] AS [o]
|
||||
INNER JOIN [Dimension].[City] AS [c]
|
||||
ON [c].[City Key] = [o].[City Key]
|
||||
WHERE [c].[State Province] IN
|
||||
('Florida', 'Georgia', 'Maryland', 'North Carolina',
|
||||
'South Carolina', 'Virginia', 'West Virginia',
|
||||
'Delaware')
|
||||
AND [o].[Order Date Key] BETWEEN @beginOrderDateKey AND @endOrderDateKey
|
||||
|
||||
IF @event = 'Hurricane - East South Central'
|
||||
INSERT @OutlierEventQuantity
|
||||
SELECT [o].[Order Key], [o].[City Key], [o].[Customer Key],
|
||||
[o].[Stock Item Key], [o].[Order Date Key], [o].[Picked Date Key],
|
||||
[o].[Salesperson Key], [o].[Picker Key],
|
||||
CASE
|
||||
WHEN [o].[Quantity] > 50 THEN [o].[Quantity] * .5
|
||||
ELSE [o].[Quantity]
|
||||
END
|
||||
FROM [Fact].[Order] AS [o]
|
||||
INNER JOIN [Dimension].[City] AS [c]
|
||||
ON [c].[City Key] = [o].[City Key]
|
||||
INNER JOIN [Dimension].[Stock Item] AS [si]
|
||||
ON [si].[Stock Item Key] = [o].[Stock Item Key]
|
||||
WHERE [c].[State Province] IN
|
||||
('Alabama', 'Kentucky', 'Mississippi', 'Tennessee')
|
||||
AND [si].[Buying Package] = 'Carton'
|
||||
AND [o].[Order Date Key] BETWEEN @beginOrderDateKey AND @endOrderDateKey
|
||||
|
||||
IF @event = 'Hurricane - West South Central'
|
||||
INSERT @OutlierEventQuantity
|
||||
SELECT [o].[Order Key], [o].[City Key], [o].[Customer Key],
|
||||
[o].[Stock Item Key], [o].[Order Date Key], [o].[Picked Date Key],
|
||||
[o].[Salesperson Key], [o].[Picker Key],
|
||||
CASE
|
||||
WHEN [cu].[Customer] = 'Unknown' THEN 0
|
||||
WHEN [cu].[Customer] <> 'Unknown' AND
|
||||
[o].[Quantity] > 10 THEN [o].[Quantity] * .5
|
||||
ELSE [o].[Quantity]
|
||||
END
|
||||
FROM [Fact].[Order] AS [o]
|
||||
INNER JOIN [Dimension].[City] AS [c]
|
||||
ON [c].[City Key] = [o].[City Key]
|
||||
INNER JOIN [Dimension].[Customer] AS [cu]
|
||||
ON [cu].[Customer Key] = [o].[Customer Key]
|
||||
WHERE [c].[State Province] IN
|
||||
('Arkansas', 'Louisiana', 'Oklahoma', 'Texas')
|
||||
AND [o].[Order Date Key] BETWEEN @beginOrderDateKey AND @endOrderDateKey
|
||||
|
||||
RETURN
|
||||
END
|
||||
GO
|
||||
|
||||
USE [master];
|
||||
GO
|
||||
|
||||
ALTER DATABASE [WideWorldImportersDW] SET COMPATIBILITY_LEVEL = 130;
|
||||
GO
|
||||
|
||||
ALTER DATABASE SCOPED CONFIGURATION CLEAR PROCEDURE_CACHE;
|
||||
GO
|
||||
|
||||
USE [WideWorldImportersDW];
|
||||
GO
|
||||
|
||||
SELECT [fo].[Order Key], [fo].[Description], [fo].[Package],
|
||||
[fo].[Quantity], [foo].[OutlierEventQuantity]
|
||||
FROM [Fact].[Order] AS [fo]
|
||||
INNER JOIN [Fact].[WhatIfOutlierEventQuantity]('Mild Recession',
|
||||
'1-01-2013',
|
||||
'10-15-2014') AS [foo] ON [fo].[Order Key] = [foo].[Order Key]
|
||||
AND [fo].[City Key] = [foo].[City Key]
|
||||
AND [fo].[Customer Key] = [foo].[Customer Key]
|
||||
AND [fo].[Stock Item Key] = [foo].[Stock Item Key]
|
||||
AND [fo].[Order Date Key] = [foo].[Order Date Key]
|
||||
AND [fo].[Picked Date Key] = [foo].[Picked Date Key]
|
||||
AND [fo].[Salesperson Key] = [foo].[Salesperson Key]
|
||||
AND [fo].[Picker Key] = [foo].[Picker Key]
|
||||
INNER JOIN [Dimension].[Stock Item] AS [si]
|
||||
ON [fo].[Stock Item Key] = [si].[Stock Item Key]
|
||||
WHERE [si].[Lead Time Days] > 0
|
||||
AND [fo].[Quantity] > 50;
|
||||
GO
|
||||
|
||||
USE [master];
|
||||
GO
|
||||
|
||||
ALTER DATABASE [WideWorldImportersDW] SET COMPATIBILITY_LEVEL = 140;
|
||||
GO
|
||||
|
||||
ALTER DATABASE SCOPED CONFIGURATION CLEAR PROCEDURE_CACHE;
|
||||
GO
|
||||
|
||||
USE [WideWorldImportersDW];
|
||||
GO
|
||||
|
||||
SELECT [fo].[Order Key], [fo].[Description], [fo].[Package],
|
||||
[fo].[Quantity], [foo].[OutlierEventQuantity]
|
||||
FROM [Fact].[Order] AS [fo]
|
||||
INNER JOIN [Fact].[WhatIfOutlierEventQuantity]('Mild Recession',
|
||||
'1-01-2013',
|
||||
'10-15-2014') AS [foo] ON [fo].[Order Key] = [foo].[Order Key]
|
||||
AND [fo].[City Key] = [foo].[City Key]
|
||||
AND [fo].[Customer Key] = [foo].[Customer Key]
|
||||
AND [fo].[Stock Item Key] = [foo].[Stock Item Key]
|
||||
AND [fo].[Order Date Key] = [foo].[Order Date Key]
|
||||
AND [fo].[Picked Date Key] = [foo].[Picked Date Key]
|
||||
AND [fo].[Salesperson Key] = [foo].[Salesperson Key]
|
||||
AND [fo].[Picker Key] = [foo].[Picker Key]
|
||||
INNER JOIN [Dimension].[Stock Item] AS [si]
|
||||
ON [fo].[Stock Item Key] = [si].[Stock Item Key]
|
||||
WHERE [si].[Lead Time Days] > 0
|
||||
AND [fo].[Quantity] > 50;
|
||||
GO
|
||||
+7
-4
@@ -10,13 +10,16 @@
|
||||
-- Email IntelligentQP@microsoft.com for questions\feedback
|
||||
-- ******************************************************** --
|
||||
|
||||
ALTER DATABASE WideWorldImportersDW SET COMPATIBILITY_LEVEL = 150;
|
||||
USE [master];
|
||||
GO
|
||||
|
||||
ALTER DATABASE [WideWorldImportersDW] SET COMPATIBILITY_LEVEL = 150;
|
||||
GO
|
||||
|
||||
ALTER DATABASE SCOPED CONFIGURATION CLEAR PROCEDURE_CACHE;
|
||||
GO
|
||||
|
||||
USE WideWorldImportersDW;
|
||||
USE [WideWorldImportersDW];
|
||||
GO
|
||||
|
||||
-- Simulate out-of-date stats
|
||||
@@ -30,10 +33,10 @@ GO
|
||||
SELECT
|
||||
fo.[Order Key], fo.Description,
|
||||
si.[Lead Time Days]
|
||||
FROM Fact.OrderHistory AS fo
|
||||
FROM Fact.OrderHistory AS fo
|
||||
INNER HASH JOIN Dimension.[Stock Item] AS si
|
||||
ON fo.[Stock Item Key] = si.[Stock Item Key]
|
||||
WHERE fo.[Lineage Key] = 9
|
||||
WHERE fo.[Lineage Key] = 9
|
||||
AND si.[Lead Time Days] > 19;
|
||||
|
||||
-- Cleanup
|
||||
|
||||
+8
-6
@@ -9,19 +9,21 @@
|
||||
|
||||
-- Email IntelligentQP@microsoft.com for questions\feedback
|
||||
-- ******************************************************** --
|
||||
USE WideWorldImportersDW;
|
||||
USE [master];
|
||||
GO
|
||||
|
||||
ALTER DATABASE WideWorldImportersDW
|
||||
SET COMPATIBILITY_LEVEL = 150;
|
||||
ALTER DATABASE [WideWorldImportersDW] SET COMPATIBILITY_LEVEL = 150;
|
||||
GO
|
||||
|
||||
ALTER DATABASE SCOPED CONFIGURATION
|
||||
CLEAR PROCEDURE_CACHE;
|
||||
ALTER DATABASE SCOPED CONFIGURATION CLEAR PROCEDURE_CACHE;
|
||||
GO
|
||||
|
||||
USE [WideWorldImportersDW];
|
||||
GO
|
||||
|
||||
/*
|
||||
Adapted from SQL Server Books Online
|
||||
https://docs.microsoft.com/en-us/sql/relational-databases/user-defined-functions/scalar-udf-inlining?view=sqlallproducts-allversions
|
||||
https://docs.microsoft.com/sql/relational-databases/user-defined-functions/scalar-udf-inlining?view=sqlallproducts-allversions
|
||||
*/
|
||||
CREATE OR ALTER FUNCTION
|
||||
dbo.customer_category(@CustomerKey INT)
|
||||
|
||||
+4
-1
@@ -13,7 +13,10 @@
|
||||
USE [master];
|
||||
GO
|
||||
|
||||
ALTER DATABASE [WideWorldImportersDW] SET COMPATIBILITY_LEVEL = 140;
|
||||
ALTER DATABASE [WideWorldImportersDW] SET COMPATIBILITY_LEVEL = 150;
|
||||
GO
|
||||
|
||||
ALTER DATABASE SCOPED CONFIGURATION CLEAR PROCEDURE_CACHE;
|
||||
GO
|
||||
|
||||
USE [WideWorldImportersDW];
|
||||
|
||||
@@ -8,6 +8,9 @@ Here are the instructions to prepare for demonstrating Intelligent QP's latest r
|
||||
|
||||
Demos (with more on the way!):
|
||||
|
||||
- [Batch Mode Adaptive Join](Intelligent%20QP%20Demos%20WideWorldImportersDW%20Public%20Preview%20-%20Batch%20Mode%20Adaptive%20Join.sql)
|
||||
- [Interleaved Execution](Intelligent%20QP%20Demos%20WideWorldImportersDW%20Public%20Preview%20-%20Interleaved%20Execution.sql)
|
||||
- [Batch mode memory grant feedback](Intelligent%20QP%20Demos%20WideWorldImportersDW%20Public%20Preview%20-%20Batch%20Mode%20MGF.sql)
|
||||
- [Row mode memory grant feedback](Intelligent%20QP%20Demos%20WideWorldImportersDW%20Public%20Preview%20-%20Row%20Mode%20MGF.sql)
|
||||
- [Batch mode on rowstore](Intelligent%20QP%20Demos%20WideWorldImportersDW%20Public%20Preview%20-%20Batch%20Mode%20on%20Rowstore.sql)
|
||||
- [APPROX_COUNT_DISTINCT](Intelligent%20QP%20Demos%20WideWorldImportersDW%20Public%20Preview%20-%20APPROX_COUNT_DISTINCT.sql)
|
||||
|
||||
@@ -46,7 +46,7 @@ if /i "%CTP_VERSION%" EQU "CTP2.4" (set MASTER_POD_NAME=mssql-master-pool-0) els
|
||||
|
||||
REM Copy the backup file, restore the database, create necessary objects and data file
|
||||
echo Copying sales database backup file to SQL Master instance...
|
||||
%DEBUG% kubectl cp tpcxbb_1gb.bak %CLUSTER_NAMESPACE%/%MASTER_POD_NAME%:/var/opt/mssql/data -c mssql-server || goto exit
|
||||
%DEBUG% kubectl cp tpcxbb_1gb.bak %CLUSTER_NAMESPACE%/%MASTER_POD_NAME%:var/opt/mssql/data -c mssql-server || goto exit
|
||||
|
||||
REM Download and copy the sample backup files
|
||||
if /i "%AW_WWI_SAMPLES%" EQU "--install-extra-samples" (
|
||||
@@ -57,7 +57,7 @@ if /i "%AW_WWI_SAMPLES%" EQU "--install-extra-samples" (
|
||||
%DEBUG% curl -L -G "https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/%%f" -o %%f
|
||||
)
|
||||
echo Copying %%f database backup file to SQL Master instance...
|
||||
%DEBUG% kubectl cp %%f %CLUSTER_NAMESPACE%/%MASTER_POD_NAME%:/var/opt/mssql/data -c mssql-server || goto exit
|
||||
%DEBUG% kubectl cp %%f %CLUSTER_NAMESPACE%/%MASTER_POD_NAME%:var/opt/mssql/data -c mssql-server || goto exit
|
||||
)
|
||||
|
||||
set FILES=WideWorldImporters-Full.bak WideWorldImportersDW-Full.bak
|
||||
@@ -67,7 +67,7 @@ if /i "%AW_WWI_SAMPLES%" EQU "--install-extra-samples" (
|
||||
%DEBUG% curl -L -G "https://github.com/Microsoft/sql-server-samples/releases/download/wide-world-importers-v1.0/%%f" -o %%f
|
||||
)
|
||||
echo Copying %%f database backup file to SQL Master instance...
|
||||
%DEBUG% kubectl cp %%f %CLUSTER_NAMESPACE%/%MASTER_POD_NAME%:/var/opt/mssql/data -c mssql-server || goto exit
|
||||
%DEBUG% kubectl cp %%f %CLUSTER_NAMESPACE%/%MASTER_POD_NAME%:var/opt/mssql/data -c mssql-server || goto exit
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -60,8 +60,8 @@ else
|
||||
MASTER_POD_NAME=master-0
|
||||
fi
|
||||
|
||||
echo Copying database backup file...
|
||||
$DEBUG kubectl cp tpcxbb_1gb.bak $CLUSTER_NAMESPACE/$MASTER_POD_NAME:/var/opt/mssql/data -c mssql-server || (echo $ERROR_MESSAGE && exit 1)
|
||||
echo Copying sales database backup file...
|
||||
$DEBUG kubectl cp tpcxbb_1gb.bak $CLUSTER_NAMESPACE/$MASTER_POD_NAME:var/opt/mssql/data -c mssql-server || (echo $ERROR_MESSAGE && exit 1)
|
||||
# $DEBUG rm tpcxbb_1gb.bak
|
||||
|
||||
if [ "$AW_WWI_SAMPLES" == "--install-extra-samples" ]
|
||||
@@ -74,7 +74,7 @@ then
|
||||
$DEBUG curl -L -G "https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/$file" -o $file
|
||||
fi
|
||||
echo Copying $file database backup file to SQL Master instance...
|
||||
$DEBUG kubectl cp $file $CLUSTER_NAMESPACE/$MASTER_POD_NAME:/var/opt/mssql/data -c mssql-server || (echo $ERROR_MESSAGE && exit 1)
|
||||
$DEBUG kubectl cp $file $CLUSTER_NAMESPACE/$MASTER_POD_NAME:var/opt/mssql/data -c mssql-server || (echo $ERROR_MESSAGE && exit 1)
|
||||
done
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ then
|
||||
$DEBUG curl -L -G "https://github.com/Microsoft/sql-server-samples/releases/download/wide-world-importers-v1.0/$file" -o $file
|
||||
fi
|
||||
echo Copying $file database backup file to SQL Master instance...
|
||||
$DEBUG kubectl cp $file $CLUSTER_NAMESPACE/$MASTER_POD_NAME:/var/opt/mssql/data -c mssql-server || (echo $ERROR_MESSAGE && exit 1)
|
||||
$DEBUG kubectl cp $file $CLUSTER_NAMESPACE/$MASTER_POD_NAME:var/opt/mssql/data -c mssql-server || (echo $ERROR_MESSAGE && exit 1)
|
||||
done
|
||||
fi
|
||||
|
||||
@@ -97,7 +97,7 @@ $DEBUG sqlcmd -S $SQL_MASTER_INSTANCE -Usa -P$SQL_MASTER_SA_PASSWORD -I -b < "$S
|
||||
|
||||
# remove files copied into the pod:
|
||||
echo Removing database backup files...
|
||||
kubectl exec $MASTER_POD_NAME -n $CLUSTER_NAMESPACE -c mssql-server -i -t -- bash -c "rm -rvf /var/opt/mssql/data/*.bak"
|
||||
$DEBUG kubectl exec $MASTER_POD_NAME -n $CLUSTER_NAMESPACE -c mssql-server -i -t -- bash -c "rm -rvf /var/opt/mssql/data/*.bak"
|
||||
|
||||
for table in web_clickstreams inventory customer
|
||||
do
|
||||
|
||||
@@ -70,8 +70,8 @@ GO
|
||||
CREATE OR ALTER PROCEDURE #create_data_sources
|
||||
AS
|
||||
BEGIN
|
||||
-- Create database master key (required for database scoped credentials used in the samples)
|
||||
IF NOT EXISTS(SELECT * FROM sys.databases WHERE name = DB_NAME() and is_master_key_encrypted_by_server = 1)
|
||||
-- Create database master key (required for database scoped credentials used in the samples)
|
||||
IF NOT EXISTS(SELECT * FROM sys.symmetric_keys WHERE name = '##MS_DatabaseMasterKey##')
|
||||
CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'sql19bigdatacluster!';
|
||||
|
||||
-- Create default data sources for SQL Big Data Cluster
|
||||
|
||||
+5
-6
@@ -4,16 +4,15 @@
|
||||
-- the Query menu, and "Specify Values for Template Parameters" option.
|
||||
IF NOT EXISTS(SELECT * FROM sys.database_scoped_credentials WHERE name = 'MySQL80-user')
|
||||
CREATE DATABASE SCOPED CREDENTIAL [MySQL80-user]
|
||||
WITH IDENTITY = 'mssql-user'
|
||||
, SECRET = 'sql19tw0mysql';
|
||||
WITH IDENTITY = '<mysql_user,nvarchar(100),mssql-user>'
|
||||
, SECRET = '<mysql_user_password,nvarchar(100),sql19tw0mysql>';
|
||||
|
||||
-- Create external data source that points to MySQL server
|
||||
-- The tokens '%u' and '%p' is used to reference the credential information.
|
||||
-- Create external data source that points to MySQL server.
|
||||
--
|
||||
IF NOT EXISTS(SELECT * FROM sys.external_data_sources WHERE name = 'MySQL80')
|
||||
CREATE EXTERNAL DATA SOURCE MySQL80
|
||||
WITH (LOCATION = 'odbc://uc-win19-vm.redmond.corp.microsoft.com'
|
||||
, CONNECTION_OPTIONS = 'Driver={MySQL ODBC 8.0 Unicode Driver};User name=%u;Passwword=%p;IGNORE_SPACE=1'
|
||||
WITH (LOCATION = 'odbc://<mysql_server,nvarchar(100),mysql-server-name>'
|
||||
, CONNECTION_OPTIONS = 'Driver={MySQL ODBC 8.0 Unicode Driver};IGNORE_SPACE=1'
|
||||
, CREDENTIAL = [MySQL80-user]);
|
||||
|
||||
-- Create external table over inventory table on MySQL server
|
||||
|
||||
+2
-3
@@ -7,13 +7,12 @@ IF NOT EXISTS(SELECT * FROM sys.database_scoped_credentials WHERE name = 'Postgr
|
||||
WITH IDENTITY = '<postgres_user,nvarchar(100),mssql-user>'
|
||||
, SECRET = '<postgres_user_password,nvarchar(100),sql19tw0postgresql>';
|
||||
|
||||
-- Create external data source that points to PostgreSQL server
|
||||
-- The tokens '%u' and '%p' is used to reference the credential information.
|
||||
-- Create external data source that points to PostgreSQL server.
|
||||
--
|
||||
IF NOT EXISTS(SELECT * FROM sys.external_data_sources WHERE name = 'PostgreSQL11')
|
||||
CREATE EXTERNAL DATA SOURCE PostgreSQL11
|
||||
WITH (LOCATION = 'odbc://<postgres_server,nvarchar(100),postgres-server-name>'
|
||||
, CONNECTION_OPTIONS = 'Driver={PostgreSQL ODBC Driver(UNICODE)};User name=%u;Passwword=%p'
|
||||
, CONNECTION_OPTIONS = 'Driver={PostgreSQL ODBC Driver(UNICODE)}'
|
||||
, CREDENTIAL = [PostgreSQL11-user]);
|
||||
|
||||
-- Create external table over inventory table on PostgreSQL server
|
||||
|
||||
+1
-1
@@ -203,7 +203,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"source": "# Configuration settings for scaling to larger data\n\n## Number and size of nodes in our Kubernetes cluster\nWe can control the number and size of nodes in our Kubernetes cluster via the node-vm-size and node-count switches in our `aks create` command:\n\n`az aks create --name mycluster --resource-group myrg --generate-ssh-keys --node-vm-size Standard_DS14_v2 --node-count 3 --kubernetes-version 1.10.9`\n\nMore information is available [here](https://docs.microsoft.com/en-us/sql/big-data-cluster/deploy-on-aks?view=sqlallproducts-allversions#create-a-kubernetes-cluster).\n\n## Number of Spark pods\nWe can control the number of Spark pods via the CLUSTER_STORAGE_POOL_REPLICAS environment variable used by `mssqlctl create cluster`:\n\nSET CLUSTER_STORAGE_POOL_REPLICAS=2\n\n## YARN scheduler memory and cores\nWe can control the YARN scheduler memory and cores via the following environment variable used by `mssqlctl create cluster`:\n\n- YARN_SCHEDULER_MAX_MEMORY\n- YARN_SCHEDULER_MAX_VCORES\n- YARN_NODEMANAGER_RESOURCE_MEMORY\n- YARN_NODEMANAGER_RESOURCE_VCORES\n\nFurther information regarding mssqlctl environtment variables is available [here](https://docs.microsoft.com/en-us/sql/big-data-cluster/deployment-guidance?view=sqlallproducts-allversions#define-environment-variables).\n\n## Livy timeout\nThe Livy timeout sets a limit on the runtime of a cell in a PySpark3 Jupyter notebook. In SQL Server 2019 Big Data CTP 2.1, the Livy timeout defaults to 1 hour. In CTP 2.2, it defaults to 24 days. One can modify this as follows:\n\n- Log into the mssql-master-pool-0 pod using this command (requires permission to run kubectl):\n\n```\nkubectl exec -it mssql-master-pool-0 -n <your-cluster-name> -- /bin/bash\n```\n- To set the Livy timeout to 24 days, run the following command or edit /livy/conf/livy.conf accordingly:\n\n```\necho 'livy.server.session.timeout = 24d' | cat >> /livy/conf/livy.conf \n```\n- Then restart the Livy server by running the following command:\n\n```\nsupervisorctl restart livy\n```",
|
||||
"source": "# Configuration settings for scaling to larger data\n\n## Number and size of nodes in our Kubernetes cluster\nWe can control the number and size of nodes in our Kubernetes cluster via the node-vm-size and node-count switches in our `aks create` command:\n\n`az aks create --name mycluster --resource-group myrg --generate-ssh-keys --node-vm-size Standard_DS14_v2 --node-count 3 --kubernetes-version 1.10.9`\n\nMore information is available [here](https://docs.microsoft.com/en-us/sql/big-data-cluster/deploy-on-aks?view=sqlallproducts-allversions#create-a-kubernetes-cluster).\n\n## Number of Spark pods\nWe can control the number of Spark pods via the CLUSTER_STORAGE_POOL_REPLICAS environment variable used by `mssqlctl create cluster`:\n\nSET CLUSTER_STORAGE_POOL_REPLICAS=2\n\n## YARN scheduler memory and cores\nWe can control the YARN scheduler memory and cores via the following environment variable used by `mssqlctl create cluster`:\n\n- YARN_SCHEDULER_MAX_MEMORY\n- YARN_SCHEDULER_MAX_VCORES\n- YARN_NODEMANAGER_RESOURCE_MEMORY\n- YARN_NODEMANAGER_RESOURCE_VCORES\n\nFurther information regarding mssqlctl environtment variables is available [here](https://docs.microsoft.com/en-us/sql/big-data-cluster/deployment-guidance?view=sqlallproducts-allversions#define-environment-variables).\n\nIn CTP 2.5 and later, these environment variables are replaced by similarly named properties in a JSON file. See [Custom configurations](https://docs.microsoft.com/en-us/sql/big-data-cluster/deployment-guidance?view=sqlallproducts-allversions#customconfig).\n\n## Livy timeout\nThe Livy timeout sets a limit on the runtime of a cell in a PySpark3 Jupyter notebook. In SQL Server 2019 Big Data CTP 2.1, the Livy timeout defaults to 1 hour. In CTP 2.2, it defaults to 24 days. One can modify this as follows:\n\n- Log into the mssql-master-pool-0 pod using this command (requires permission to run kubectl):\n\n```\nkubectl exec -it mssql-master-pool-0 -n <your-cluster-name> -- /bin/bash\n```\n- To set the Livy timeout to 24 days, run the following command or edit /livy/conf/livy.conf accordingly:\n\n```\necho 'livy.server.session.timeout = 24d' | cat >> /livy/conf/livy.conf \n```\n- Then restart the Livy server by running the following command:\n\n```\nsupervisorctl restart livy\n```",
|
||||
"metadata": {}
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user