Skip to content

Commit 54771cc

Browse files
author
pmasl
committed
Updated IQP demos
1 parent 87bf25d commit 54771cc

10 files changed

Lines changed: 92 additions & 89 deletions

samples/features/intelligent-query-processing/Intelligent QP Demo - APPROX_COUNT_DISTINCT.sql renamed to samples/features/intelligent-query-processing/IQP Demo - APPROX_COUNT_DISTINCT.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
-- Demo scripts: https://aka.ms/IQPDemos
77

8-
-- Demo uses SQL Server 2019 Public Preview and also works on Azure SQL DB
8+
-- Demo uses SQL Server 2019 and Azure SQL DB
99

1010
-- Email IntelligentQP@microsoft.com for questions\feedback
1111
-- ******************************************************** --

samples/features/intelligent-query-processing/Intelligent QP Demo - Batch Mode Adaptive Join.sql renamed to samples/features/intelligent-query-processing/IQP Demo - Batch Mode Adaptive Join.sql

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@ DELETE [Fact].[Order]
3535
WHERE Quantity = 361;
3636

3737
INSERT [Fact].[Order]
38-
([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])
38+
([City Key], [Customer Key], [Stock Item Key], [Order Date Key], [Picked Date Key], [Salesperson Key],
39+
[Picker Key], [WWI Order ID], [WWI Backorder ID], Description, Package, Quantity, [Unit Price], [Tax Rate],
40+
[Total Excluding Tax], [Tax Amount], [Total Including Tax], [Lineage Key])
3941
SELECT TOP 5 [City Key], [Customer Key], [Stock Item Key],
40-
[Order Date Key], [Picked Date Key], [Salesperson Key],
41-
[Picker Key], [WWI Order ID], [WWI Backorder ID],
42-
Description, Package, 361, [Unit Price], [Tax Rate],
43-
[Total Excluding Tax], [Tax Amount], [Total Including Tax],
44-
[Lineage Key]
42+
[Order Date Key], [Picked Date Key], [Salesperson Key],
43+
[Picker Key], [WWI Order ID], [WWI Backorder ID],
44+
Description, Package, 361, [Unit Price], [Tax Rate],
45+
[Total Excluding Tax], [Tax Amount], [Total Including Tax],
46+
[Lineage Key]
4547
FROM [Fact].[Order];
4648
GO
4749

samples/features/intelligent-query-processing/Intelligent QP Demo - Batch Mode MGF.sql renamed to samples/features/intelligent-query-processing/IQP Demo - Batch Mode MGF.sql

File renamed without changes.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
-- ******************************************************** --
2+
-- Batch mode on rowstore
3+
4+
-- See https://aka.ms/IQP for more background
5+
6+
-- Demo scripts: https://aka.ms/IQPDemos
7+
8+
-- This demo is on SQL Server 2019 and Azure SQL DB
9+
10+
-- Email IntelligentQP@microsoft.com for questions\feedback
11+
-- ******************************************************** --
12+
13+
USE [master];
14+
GO
15+
16+
ALTER DATABASE [WideWorldImportersDW] SET COMPATIBILITY_LEVEL = 150;
17+
GO
18+
19+
ALTER DATABASE SCOPED CONFIGURATION CLEAR PROCEDURE_CACHE;
20+
GO
21+
22+
USE [WideWorldImportersDW];
23+
GO
24+
25+
-- Row mode due to hint
26+
SELECT [Tax Rate],
27+
[Lineage Key],
28+
[Salesperson Key],
29+
SUM([Quantity]) AS SUM_QTY,
30+
SUM([Unit Price]) AS SUM_BASE_PRICE,
31+
COUNT(*) AS COUNT_ORDER
32+
FROM [Fact].[OrderHistoryExtended]
33+
WHERE [Order Date Key] <= DATEADD(dd, -73, '2015-11-13')
34+
GROUP BY [Tax Rate],
35+
[Lineage Key],
36+
[Salesperson Key]
37+
ORDER BY [Tax Rate],
38+
[Lineage Key],
39+
[Salesperson Key]
40+
OPTION (RECOMPILE, USE HINT('DISALLOW_BATCH_MODE'));
41+
42+
-- Batch mode on rowstore eligible
43+
SELECT [Tax Rate],
44+
[Lineage Key],
45+
[Salesperson Key],
46+
SUM([Quantity]) AS SUM_QTY,
47+
SUM([Unit Price]) AS SUM_BASE_PRICE,
48+
COUNT(*) AS COUNT_ORDER
49+
FROM [Fact].[OrderHistoryExtended]
50+
WHERE [Order Date Key] <= DATEADD(dd, -73, '2015-11-13')
51+
GROUP BY [Tax Rate],
52+
[Lineage Key],
53+
[Salesperson Key]
54+
ORDER BY [Tax Rate],
55+
[Lineage Key],
56+
[Salesperson Key]
57+
OPTION (RECOMPILE);

samples/features/intelligent-query-processing/Intelligent QP Demo - Interleaved Execution.sql renamed to samples/features/intelligent-query-processing/IQP Demo - Interleaved Execution.sql

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ USE [WideWorldImportersDW];
2222
GO
2323

2424
CREATE OR ALTER FUNCTION [Fact].[ufn_WhatIfOutlierEventQuantity]
25-
(@event VARCHAR(30), @beginOrderDateKey DATE, @endOrderDateKey DATE)
25+
(@event VARCHAR(30), @beginOrderDateKey DATE, @endOrderDateKey DATE)
2626
RETURNS @OutlierEventQuantity TABLE (
2727
[Order Key] [bigint],
2828
[City Key] [int] NOT NULL,
@@ -68,13 +68,13 @@ BEGIN
6868
INNER JOIN [Dimension].[City] AS [c]
6969
ON [c].[City Key] = [o].[City Key]
7070
WHERE [c].[State Province] IN
71-
('Florida', 'Georgia', 'Maryland', 'North Carolina',
72-
'South Carolina', 'Virginia', 'West Virginia',
73-
'Delaware')
71+
('Florida', 'Georgia', 'Maryland', 'North Carolina',
72+
'South Carolina', 'Virginia', 'West Virginia',
73+
'Delaware')
7474
AND [o].[Order Date Key] BETWEEN @beginOrderDateKey AND @endOrderDateKey
7575

7676
IF @event = 'Hurricane - East South Central'
77-
INSERT @OutlierEventQuantity
77+
INSERT @OutlierEventQuantity
7878
SELECT [o].[Order Key], [o].[City Key], [o].[Customer Key],
7979
[o].[Stock Item Key], [o].[Order Date Key], [o].[Picked Date Key],
8080
[o].[Salesperson Key], [o].[Picker Key],
@@ -86,14 +86,14 @@ BEGIN
8686
INNER JOIN [Dimension].[City] AS [c]
8787
ON [c].[City Key] = [o].[City Key]
8888
INNER JOIN [Dimension].[Stock Item] AS [si]
89-
ON [si].[Stock Item Key] = [o].[Stock Item Key]
89+
ON [si].[Stock Item Key] = [o].[Stock Item Key]
9090
WHERE [c].[State Province] IN
9191
('Alabama', 'Kentucky', 'Mississippi', 'Tennessee')
9292
AND [si].[Buying Package] = 'Carton'
9393
AND [o].[Order Date Key] BETWEEN @beginOrderDateKey AND @endOrderDateKey
9494

9595
IF @event = 'Hurricane - West South Central'
96-
INSERT @OutlierEventQuantity
96+
INSERT @OutlierEventQuantity
9797
SELECT [o].[Order Key], [o].[City Key], [o].[Customer Key],
9898
[o].[Stock Item Key], [o].[Order Date Key], [o].[Picked Date Key],
9999
[o].[Salesperson Key], [o].[Picker Key],
@@ -107,7 +107,7 @@ BEGIN
107107
INNER JOIN [Dimension].[City] AS [c]
108108
ON [c].[City Key] = [o].[City Key]
109109
INNER JOIN [Dimension].[Customer] AS [cu]
110-
ON [cu].[Customer Key] = [o].[Customer Key]
110+
ON [cu].[Customer Key] = [o].[Customer Key]
111111
WHERE [c].[State Province] IN
112112
('Arkansas', 'Louisiana', 'Oklahoma', 'Texas')
113113
AND [o].[Order Date Key] BETWEEN @beginOrderDateKey AND @endOrderDateKey

samples/features/intelligent-query-processing/Intelligent QP Demo - Row Mode MGF.sql renamed to samples/features/intelligent-query-processing/IQP Demo - Row Mode MGF.sql

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- See https://aka.ms/IQP for more background
55
-- Demo scripts: https://aka.ms/IQPDemos
66

7-
-- This demo is on SQL Server 2019 Public Preview and works in Azure SQL DB too
7+
-- This demo is on SQL Server 2019 and Azure SQL DB
88
-- SSMS v17.9 or higher
99

1010
-- Email IntelligentQP@microsoft.com for questions\feedback
@@ -30,8 +30,7 @@ GO
3030
-- Include actual execution plan
3131
-- Execute once to see spills (row mode)
3232
-- Execute a second time to see correction
33-
SELECT
34-
fo.[Order Key], fo.Description,
33+
SELECT fo.[Order Key], fo.Description,
3534
si.[Lead Time Days]
3635
FROM Fact.OrderHistory AS fo
3736
INNER HASH JOIN Dimension.[Stock Item] AS si

samples/features/intelligent-query-processing/Intelligent QP Demo - Scalar UDF Inlining.sql renamed to samples/features/intelligent-query-processing/IQP Demo - Scalar UDF Inlining.sql

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
-- Demo scripts: https://aka.ms/IQPDemos
77

8-
-- Demo uses SQL Server 2019 Public Preview and also works on Azure SQL DB
8+
-- Demo uses SQL Server 2019 and Azure SQL DB
99

1010
-- Email IntelligentQP@microsoft.com for questions\feedback
1111
-- ******************************************************** --
@@ -23,28 +23,27 @@ GO
2323

2424
/*
2525
Adapted from SQL Server Books Online
26-
https://docs.microsoft.com/sql/relational-databases/user-defined-functions/scalar-udf-inlining?view=sqlallproducts-allversions
26+
https://docs.microsoft.com/sql/relational-databases/user-defined-functions/scalar-udf-inlining
2727
*/
2828
CREATE OR ALTER FUNCTION
2929
dbo.ufn_customer_category(@CustomerKey INT)
3030
RETURNS CHAR(10) AS
3131
BEGIN
32-
DECLARE @total_amount DECIMAL(18,2);
33-
DECLARE @category CHAR(10);
32+
DECLARE @total_amount DECIMAL(18,2);
33+
DECLARE @category CHAR(10);
3434

35-
SELECT @total_amount =
36-
SUM([Total Including Tax])
35+
SELECT @total_amount = SUM([Total Including Tax])
3736
FROM [Fact].[OrderHistory]
3837
WHERE [Customer Key] = @CustomerKey;
3938

40-
IF @total_amount < 500000
41-
SET @category = 'REGULAR';
42-
ELSE IF @total_amount < 1000000
43-
SET @category = 'GOLD';
44-
ELSE
45-
SET @category = 'PLATINUM';
39+
IF @total_amount < 500000
40+
SET @category = 'REGULAR';
41+
ELSE IF @total_amount < 1000000
42+
SET @category = 'GOLD';
43+
ELSE
44+
SET @category = 'PLATINUM';
4645

47-
RETURN @category;
46+
RETURN @category;
4847
END
4948
GO
5049

samples/features/intelligent-query-processing/Intelligent QP Demo - TVDC.sql renamed to samples/features/intelligent-query-processing/IQP Demo - TVDC.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
-- Demo scripts: https://aka.ms/IQPDemos
77

8-
-- This demo is on SQL Server 2019 Public Preview and works in Azure SQL DB too
8+
-- This demo is on SQL Server 2019 and Azure SQL DB
99

1010
-- Email IntelligentQP@microsoft.com for questions\feedback
1111
-- ******************************************************** --
@@ -34,7 +34,7 @@ WHERE [Quantity] > 99;
3434

3535
-- Look at estimated rows, speed, join algorithm
3636
SELECT oh.[Order Key], oh.[Order Date Key],
37-
oh.[Unit Price], o.Quantity
37+
oh.[Unit Price], o.Quantity
3838
FROM Fact.OrderHistoryExtended AS oh
3939
INNER JOIN @Order AS o
4040
ON o.[Order Key] = oh.[Order Key]
@@ -59,11 +59,11 @@ DECLARE @Order TABLE
5959
INSERT @Order
6060
SELECT [Order Key], [Quantity]
6161
FROM [Fact].[OrderHistory]
62-
WHERE [Quantity] > 99;
62+
WHERE [Quantity] > 99;
6363

6464
-- Look at estimated rows, speed, join algorithm
6565
SELECT oh.[Order Key], oh.[Order Date Key],
66-
oh.[Unit Price], o.Quantity
66+
oh.[Unit Price], o.Quantity
6767
FROM Fact.OrderHistoryExtended AS oh
6868
INNER JOIN @Order AS o
6969
ON o.[Order Key] = oh.[Order Key]

samples/features/intelligent-query-processing/Intelligent QP Demo Setup - Enlarging WideWorldImportersDW.sql renamed to samples/features/intelligent-query-processing/IQP Demo Setup - Enlarging WideWorldImportersDW.sql

File renamed without changes.

samples/features/intelligent-query-processing/Intelligent QP Demo - Batch Mode on Rowstore.sql

Lines changed: 0 additions & 54 deletions
This file was deleted.

0 commit comments

Comments
 (0)