diff --git a/samples/features/intelligent-query-processing/Intelligent QP Demo - APPROX_COUNT_DISTINCT.sql b/samples/features/intelligent-query-processing/IQP Demo - APPROX_COUNT_DISTINCT.sql similarity index 91% rename from samples/features/intelligent-query-processing/Intelligent QP Demo - APPROX_COUNT_DISTINCT.sql rename to samples/features/intelligent-query-processing/IQP Demo - APPROX_COUNT_DISTINCT.sql index 2bf41899..ea913b83 100644 --- a/samples/features/intelligent-query-processing/Intelligent QP Demo - APPROX_COUNT_DISTINCT.sql +++ b/samples/features/intelligent-query-processing/IQP Demo - APPROX_COUNT_DISTINCT.sql @@ -5,7 +5,7 @@ -- Demo scripts: https://aka.ms/IQPDemos --- Demo uses SQL Server 2019 Public Preview and also works on Azure SQL DB +-- Demo uses SQL Server 2019 and Azure SQL DB -- Email IntelligentQP@microsoft.com for questions\feedback -- ******************************************************** -- diff --git a/samples/features/intelligent-query-processing/Intelligent QP Demo - Batch Mode Adaptive Join.sql b/samples/features/intelligent-query-processing/IQP Demo - Batch Mode Adaptive Join.sql similarity index 70% rename from samples/features/intelligent-query-processing/Intelligent QP Demo - Batch Mode Adaptive Join.sql rename to samples/features/intelligent-query-processing/IQP Demo - Batch Mode Adaptive Join.sql index b5a70078..a30ee923 100644 --- a/samples/features/intelligent-query-processing/Intelligent QP Demo - Batch Mode Adaptive Join.sql +++ b/samples/features/intelligent-query-processing/IQP Demo - Batch Mode Adaptive Join.sql @@ -35,13 +35,15 @@ 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]) + ([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] + [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 diff --git a/samples/features/intelligent-query-processing/Intelligent QP Demo - Batch Mode MGF.sql b/samples/features/intelligent-query-processing/IQP Demo - Batch Mode MGF.sql similarity index 100% rename from samples/features/intelligent-query-processing/Intelligent QP Demo - Batch Mode MGF.sql rename to samples/features/intelligent-query-processing/IQP Demo - Batch Mode MGF.sql diff --git a/samples/features/intelligent-query-processing/IQP Demo - Batch Mode on Rowstore.sql b/samples/features/intelligent-query-processing/IQP Demo - Batch Mode on Rowstore.sql new file mode 100644 index 00000000..1d0eb36e --- /dev/null +++ b/samples/features/intelligent-query-processing/IQP Demo - Batch Mode on Rowstore.sql @@ -0,0 +1,57 @@ +-- ******************************************************** -- +-- Batch mode on rowstore + +-- See https://aka.ms/IQP for more background + +-- Demo scripts: https://aka.ms/IQPDemos + +-- This demo is on SQL Server 2019 and Azure SQL DB + +-- 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], + [Salesperson Key], + SUM([Quantity]) AS SUM_QTY, + SUM([Unit Price]) AS SUM_BASE_PRICE, + COUNT(*) AS COUNT_ORDER +FROM [Fact].[OrderHistoryExtended] +WHERE [Order Date Key] <= DATEADD(dd, -73, '2015-11-13') +GROUP BY [Tax Rate], + [Lineage Key], + [Salesperson Key] +ORDER BY [Tax Rate], + [Lineage Key], + [Salesperson Key] +OPTION (RECOMPILE, USE HINT('DISALLOW_BATCH_MODE')); + +-- Batch mode on rowstore eligible +SELECT [Tax Rate], + [Lineage Key], + [Salesperson Key], + SUM([Quantity]) AS SUM_QTY, + SUM([Unit Price]) AS SUM_BASE_PRICE, + COUNT(*) AS COUNT_ORDER +FROM [Fact].[OrderHistoryExtended] +WHERE [Order Date Key] <= DATEADD(dd, -73, '2015-11-13') +GROUP BY [Tax Rate], + [Lineage Key], + [Salesperson Key] +ORDER BY [Tax Rate], + [Lineage Key], + [Salesperson Key] +OPTION (RECOMPILE); \ No newline at end of file diff --git a/samples/features/intelligent-query-processing/Intelligent QP Demo - Interleaved Execution.sql b/samples/features/intelligent-query-processing/IQP Demo - Interleaved Execution.sql similarity index 94% rename from samples/features/intelligent-query-processing/Intelligent QP Demo - Interleaved Execution.sql rename to samples/features/intelligent-query-processing/IQP Demo - Interleaved Execution.sql index ce664ed7..5f58af7f 100644 --- a/samples/features/intelligent-query-processing/Intelligent QP Demo - Interleaved Execution.sql +++ b/samples/features/intelligent-query-processing/IQP Demo - Interleaved Execution.sql @@ -22,7 +22,7 @@ USE [WideWorldImportersDW]; GO CREATE OR ALTER FUNCTION [Fact].[ufn_WhatIfOutlierEventQuantity] -(@event VARCHAR(30), @beginOrderDateKey DATE, @endOrderDateKey DATE) + (@event VARCHAR(30), @beginOrderDateKey DATE, @endOrderDateKey DATE) RETURNS @OutlierEventQuantity TABLE ( [Order Key] [bigint], [City Key] [int] NOT NULL, @@ -68,13 +68,13 @@ BEGIN 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') + ('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 + 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], @@ -86,14 +86,14 @@ BEGIN 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] + 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 + 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], @@ -107,7 +107,7 @@ BEGIN 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] + 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 diff --git a/samples/features/intelligent-query-processing/Intelligent QP Demo - Row Mode MGF.sql b/samples/features/intelligent-query-processing/IQP Demo - Row Mode MGF.sql similarity index 89% rename from samples/features/intelligent-query-processing/Intelligent QP Demo - Row Mode MGF.sql rename to samples/features/intelligent-query-processing/IQP Demo - Row Mode MGF.sql index 698b32cc..cb0ea3c2 100644 --- a/samples/features/intelligent-query-processing/Intelligent QP Demo - Row Mode MGF.sql +++ b/samples/features/intelligent-query-processing/IQP Demo - Row Mode MGF.sql @@ -4,7 +4,7 @@ -- See https://aka.ms/IQP for more background -- Demo scripts: https://aka.ms/IQPDemos --- This demo is on SQL Server 2019 Public Preview and works in Azure SQL DB too +-- This demo is on SQL Server 2019 and Azure SQL DB -- SSMS v17.9 or higher -- Email IntelligentQP@microsoft.com for questions\feedback @@ -30,8 +30,7 @@ GO -- Include actual execution plan -- Execute once to see spills (row mode) -- Execute a second time to see correction -SELECT - fo.[Order Key], fo.Description, +SELECT fo.[Order Key], fo.Description, si.[Lead Time Days] FROM Fact.OrderHistory AS fo INNER HASH JOIN Dimension.[Stock Item] AS si diff --git a/samples/features/intelligent-query-processing/Intelligent QP Demo - Scalar UDF Inlining.sql b/samples/features/intelligent-query-processing/IQP Demo - Scalar UDF Inlining.sql similarity index 76% rename from samples/features/intelligent-query-processing/Intelligent QP Demo - Scalar UDF Inlining.sql rename to samples/features/intelligent-query-processing/IQP Demo - Scalar UDF Inlining.sql index 10253f77..43974234 100644 --- a/samples/features/intelligent-query-processing/Intelligent QP Demo - Scalar UDF Inlining.sql +++ b/samples/features/intelligent-query-processing/IQP Demo - Scalar UDF Inlining.sql @@ -5,7 +5,7 @@ -- Demo scripts: https://aka.ms/IQPDemos --- Demo uses SQL Server 2019 Public Preview and also works on Azure SQL DB +-- Demo uses SQL Server 2019 and Azure SQL DB -- Email IntelligentQP@microsoft.com for questions\feedback -- ******************************************************** -- @@ -23,28 +23,27 @@ GO /* Adapted from SQL Server Books Online -https://docs.microsoft.com/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 */ CREATE OR ALTER FUNCTION dbo.ufn_customer_category(@CustomerKey INT) RETURNS CHAR(10) AS BEGIN - DECLARE @total_amount DECIMAL(18,2); - DECLARE @category CHAR(10); + DECLARE @total_amount DECIMAL(18,2); + DECLARE @category CHAR(10); - SELECT @total_amount = - SUM([Total Including Tax]) + SELECT @total_amount = SUM([Total Including Tax]) FROM [Fact].[OrderHistory] WHERE [Customer Key] = @CustomerKey; - IF @total_amount < 500000 - SET @category = 'REGULAR'; - ELSE IF @total_amount < 1000000 - SET @category = 'GOLD'; - ELSE - SET @category = 'PLATINUM'; + IF @total_amount < 500000 + SET @category = 'REGULAR'; + ELSE IF @total_amount < 1000000 + SET @category = 'GOLD'; + ELSE + SET @category = 'PLATINUM'; - RETURN @category; + RETURN @category; END GO diff --git a/samples/features/intelligent-query-processing/Intelligent QP Demo - TVDC.sql b/samples/features/intelligent-query-processing/IQP Demo - TVDC.sql similarity index 89% rename from samples/features/intelligent-query-processing/Intelligent QP Demo - TVDC.sql rename to samples/features/intelligent-query-processing/IQP Demo - TVDC.sql index 91acb05c..161f4b2f 100644 --- a/samples/features/intelligent-query-processing/Intelligent QP Demo - TVDC.sql +++ b/samples/features/intelligent-query-processing/IQP Demo - TVDC.sql @@ -5,7 +5,7 @@ -- Demo scripts: https://aka.ms/IQPDemos --- This demo is on SQL Server 2019 Public Preview and works in Azure SQL DB too +-- This demo is on SQL Server 2019 and Azure SQL DB -- Email IntelligentQP@microsoft.com for questions\feedback -- ******************************************************** -- @@ -34,7 +34,7 @@ WHERE [Quantity] > 99; -- Look at estimated rows, speed, join algorithm SELECT oh.[Order Key], oh.[Order Date Key], - oh.[Unit Price], o.Quantity + oh.[Unit Price], o.Quantity FROM Fact.OrderHistoryExtended AS oh INNER JOIN @Order AS o ON o.[Order Key] = oh.[Order Key] @@ -59,11 +59,11 @@ DECLARE @Order TABLE INSERT @Order SELECT [Order Key], [Quantity] FROM [Fact].[OrderHistory] -WHERE [Quantity] > 99; +WHERE [Quantity] > 99; -- Look at estimated rows, speed, join algorithm SELECT oh.[Order Key], oh.[Order Date Key], - oh.[Unit Price], o.Quantity + oh.[Unit Price], o.Quantity FROM Fact.OrderHistoryExtended AS oh INNER JOIN @Order AS o ON o.[Order Key] = oh.[Order Key] diff --git a/samples/features/intelligent-query-processing/Intelligent QP Demo Setup - Enlarging WideWorldImportersDW.sql b/samples/features/intelligent-query-processing/IQP Demo Setup - Enlarging WideWorldImportersDW.sql similarity index 100% rename from samples/features/intelligent-query-processing/Intelligent QP Demo Setup - Enlarging WideWorldImportersDW.sql rename to samples/features/intelligent-query-processing/IQP Demo Setup - Enlarging WideWorldImportersDW.sql diff --git a/samples/features/intelligent-query-processing/Intelligent QP Demo - Batch Mode on Rowstore.sql b/samples/features/intelligent-query-processing/Intelligent QP Demo - Batch Mode on Rowstore.sql deleted file mode 100644 index 0ec77748..00000000 --- a/samples/features/intelligent-query-processing/Intelligent QP Demo - Batch Mode on Rowstore.sql +++ /dev/null @@ -1,54 +0,0 @@ --- ******************************************************** -- --- Batch mode on rowstore - --- See https://aka.ms/IQP for more background - --- Demo scripts: https://aka.ms/IQPDemos - --- This demo is on SQL Server 2019 Public Preview and coming soon to Azure SQL DB - --- 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], - SUM([Quantity]) AS SUM_QTY, - SUM([Unit Price]) AS SUM_BASE_PRICE, - COUNT(*) AS COUNT_ORDER -FROM [Fact].[OrderHistoryExtended] -WHERE [Order Date Key] <= dateadd(dd, -73, '2015-11-13') -GROUP BY [Tax Rate], - [Lineage Key] -ORDER BY [Tax Rate], - [Lineage Key] -OPTION (RECOMPILE, USE HINT('DISALLOW_BATCH_MODE')); - --- Batch mode on rowstore eligible -SELECT [Tax Rate], - [Lineage Key], - [Salesperson Key], - SUM([Quantity]) AS SUM_QTY, - SUM([Unit Price]) AS SUM_BASE_PRICE, - COUNT(*) AS COUNT_ORDER -FROM [Fact].[OrderHistoryExtended] -WHERE [Order Date Key] <= dateadd(dd, -73, '2015-11-13') -GROUP BY [Tax Rate], - [Lineage Key], - [Salesperson Key] -ORDER BY [Tax Rate], - [Lineage Key], - [Salesperson Key] -OPTION (RECOMPILE); \ No newline at end of file