From c8a7012f5bc0142aad5832c86b65f2e5bede641c Mon Sep 17 00:00:00 2001 From: pmasl Date: Thu, 20 Jun 2019 12:42:52 -0700 Subject: [PATCH] Updated IQP demos --- ...P Demos Enlarging WideWorldImportersDW.sql | 6 ++++++ ...Public Preview - Interleaved Execution.sql | 18 +++++++++--------- ...W Public Preview - Scalar UDF Inlining.sql | 13 +++++++++---- ...WorldImportersDW Public Preview - TVDC.sql | 4 ++-- .../query-store/QueryStoreSimpleDemo.exe | Bin 43520 -> 44544 bytes 5 files changed, 26 insertions(+), 15 deletions(-) diff --git a/samples/features/intelligent-query-processing/Intelligent QP Demos Enlarging WideWorldImportersDW.sql b/samples/features/intelligent-query-processing/Intelligent QP Demos Enlarging WideWorldImportersDW.sql index 842613ba..9ebea812 100644 --- a/samples/features/intelligent-query-processing/Intelligent QP Demos Enlarging WideWorldImportersDW.sql +++ b/samples/features/intelligent-query-processing/Intelligent QP Demos Enlarging WideWorldImportersDW.sql @@ -100,4 +100,10 @@ GO UPDATE Fact.OrderHistoryExtended SET [WWI Order ID] = [Order Key]; +GO + +-- Repeat until log shrinks +CHECKPOINT +GO +DBCC SHRINKFILE (N'WWI_Log' , 0, TRUNCATEONLY) GO \ No newline at end of file diff --git a/samples/features/intelligent-query-processing/Intelligent QP Demos WideWorldImportersDW Public Preview - Interleaved Execution.sql b/samples/features/intelligent-query-processing/Intelligent QP Demos WideWorldImportersDW Public Preview - Interleaved Execution.sql index eb2c1161..176bf13a 100644 --- a/samples/features/intelligent-query-processing/Intelligent QP Demos WideWorldImportersDW Public Preview - Interleaved Execution.sql +++ b/samples/features/intelligent-query-processing/Intelligent QP Demos WideWorldImportersDW Public Preview - Interleaved Execution.sql @@ -17,7 +17,7 @@ USE [WideWorldImportersDW]; GO -CREATE FUNCTION [Fact].[WhatIfOutlierEventQuantity](@event VARCHAR(15), @beginOrderDateKey DATE, @endOrderDateKey DATE) +CREATE OR ALTER FUNCTION [Fact].[ufn_WhatIfOutlierEventQuantity](@event VARCHAR(15), @beginOrderDateKey DATE, @endOrderDateKey DATE) RETURNS @OutlierEventQuantity TABLE ( [Order Key] [bigint], [City Key] [int] NOT NULL, @@ -122,10 +122,10 @@ GO USE [WideWorldImportersDW]; GO -SELECT [fo].[Order Key], [fo].[Description], [fo].[Package], +SELECT [fo].[Order Key], [fo].[Description], [fo].[Package], [fo].[Quantity], [foo].[OutlierEventQuantity] -FROM [Fact].[Order] AS [fo] -INNER JOIN [Fact].[WhatIfOutlierEventQuantity]('Mild Recession', +FROM [Fact].[Order] AS [fo] +INNER JOIN [Fact].[ufn_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] @@ -137,7 +137,7 @@ INNER JOIN [Fact].[WhatIfOutlierEventQuantity]('Mild Recession', 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 +WHERE [si].[Lead Time Days] > 0 AND [fo].[Quantity] > 50; GO @@ -153,10 +153,10 @@ GO USE [WideWorldImportersDW]; GO -SELECT [fo].[Order Key], [fo].[Description], [fo].[Package], +SELECT [fo].[Order Key], [fo].[Description], [fo].[Package], [fo].[Quantity], [foo].[OutlierEventQuantity] -FROM [Fact].[Order] AS [fo] -INNER JOIN [Fact].[WhatIfOutlierEventQuantity]('Mild Recession', +FROM [Fact].[Order] AS [fo] +INNER JOIN [Fact].[ufn_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] @@ -168,6 +168,6 @@ INNER JOIN [Fact].[WhatIfOutlierEventQuantity]('Mild Recession', 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 +WHERE [si].[Lead Time Days] > 0 AND [fo].[Quantity] > 50; GO diff --git a/samples/features/intelligent-query-processing/Intelligent QP Demos WideWorldImportersDW Public Preview - Scalar UDF Inlining.sql b/samples/features/intelligent-query-processing/Intelligent QP Demos WideWorldImportersDW Public Preview - Scalar UDF Inlining.sql index e5b2124a..c6e687e7 100644 --- a/samples/features/intelligent-query-processing/Intelligent QP Demos WideWorldImportersDW Public Preview - Scalar UDF Inlining.sql +++ b/samples/features/intelligent-query-processing/Intelligent QP Demos WideWorldImportersDW Public Preview - Scalar UDF Inlining.sql @@ -26,7 +26,7 @@ Adapted from SQL Server Books Online 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) + dbo.ufn_customer_category(@CustomerKey INT) RETURNS CHAR(10) AS BEGIN DECLARE @total_amount DECIMAL(18,2); @@ -48,20 +48,25 @@ BEGIN END GO +SELECT * FROM sys.sql_modules +WHERE object_id = OBJECT_ID('ufn_customer_category') +GO + -- Before (show actual query execution plan for legacy behavior) SELECT TOP 100 [Customer Key], [Customer], - dbo.customer_category([Customer Key]) AS [Discount Price] + dbo.ufn_customer_category([Customer Key]) AS [Discount Price] FROM [Dimension].[Customer] ORDER BY [Customer Key] OPTION (RECOMPILE,USE HINT('DISABLE_TSQL_SCALAR_UDF_INLINING')); +GO -- After (show actual query execution plan for Scalar UDF Inlining) SELECT TOP 100 [Customer Key], [Customer], - dbo.customer_category([Customer Key]) AS [Discount Price] + dbo.ufn_customer_category([Customer Key]) AS [Discount Price] FROM [Dimension].[Customer] ORDER BY [Customer Key] OPTION (RECOMPILE); - +GO diff --git a/samples/features/intelligent-query-processing/Intelligent QP Demos WideWorldImportersDW Public Preview - TVDC.sql b/samples/features/intelligent-query-processing/Intelligent QP Demos WideWorldImportersDW Public Preview - TVDC.sql index 6277b4a1..e1a405dd 100644 --- a/samples/features/intelligent-query-processing/Intelligent QP Demos WideWorldImportersDW Public Preview - TVDC.sql +++ b/samples/features/intelligent-query-processing/Intelligent QP Demos WideWorldImportersDW Public Preview - TVDC.sql @@ -13,7 +13,7 @@ USE [master]; GO -ALTER DATABASE [WideWorldImportersDW] SET COMPATIBILITY_LEVEL = 150; +ALTER DATABASE [WideWorldImportersDW] SET COMPATIBILITY_LEVEL = 140; GO ALTER DATABASE SCOPED CONFIGURATION CLEAR PROCEDURE_CACHE; @@ -30,7 +30,7 @@ DECLARE @Order TABLE INSERT @Order SELECT [Order Key], [Quantity] FROM [Fact].[OrderHistory] -WHERE [Quantity] > 1; +WHERE [Quantity] > 99; -- Look at estimated rows, speed, join algorithm SELECT oh.[Order Key], oh.[Order Date Key], diff --git a/samples/features/query-store/QueryStoreSimpleDemo.exe b/samples/features/query-store/QueryStoreSimpleDemo.exe index d2611cff752e8450e004a4cb4a380a7ebace32e0..e3c4fbe8746c4c0a718df5701e9e5bd81c63d727 100644 GIT binary patch delta 850 zcmaLVQAkr^6bJD0-RW@7=B8$8EAN~(&C6I1MIxEnhGtf>X_jVMq7~|#3&E%Ev>wDD z9A7;ZPQ|2$h~P%xQ%WyV;DZG{tYTOX5eP!P7X43Zj~zICzwgiC-pl30-Yc<>%G5;T zVjp$VcBQD8tine$haht+ytRx|MW@hIvt@-Sjjt&4)`2{}=Cx^yj6mClj%0SP{m!il*f(Xy2r}DEXR=e>)t_HM1>7-Q? zt&9|k558)Yg+VsHMEQMI{?{OZ4FR1OKpVgtO=Hb zb^J7x!#dvt<+3`?LV2uX&CqVvTUI`+B?#>y9ZZD4y&T?eg$h`KHmLCLU^}#rRo?+Q zSE&;i!vE~tp5cS9;|bA{SyM%%gn>OIZcipo1*$ zb;!f2yaAQ5s2?h4-5!7rvC_g&1#5$)vC1McS@fWAYM98~8lpU%2!D*+^{uD;I7@V6 zQms9sjCaVfXp{UlurB>Wb|X3H6eclNu^p~u_fs#0$wwZlA~D{!lUx4fvUVs}CI>fV z>9A({|3omV31R5b%5wYY;Jshd>!17!BhP1hYTvvwRvtc4w4IgaEplQ>>`Ul5qF~4$ zvYmL5Ugup4EY_uWjeIHiU_6@65IHT&7~QTgTaCN&mF{J^ny8U#VpQ5@ZiR^iVHB&;&F39%nx|_k4bb-{t(c_ryO-@%PfL z$*!bfv7a_po@`Vm+(gqT7>dQ;8DtreMNnJO5>W|nv9!g6XCk-9l)~vFT*(p{wFzsr zF%MurxJYDHtddLV6OD#H_fV1%)5?^v>$8v!F{3;a7JVK<1DaR92%Egj{jvNAiAu@U zid$SG(qJdhUP&a~YEas19{0D?P`nH`8y@jM=vp%Ty%j2FB|9J!>#Y~s#Jb~yDp=GB zRkEJ4s#tIQP&Mma7qpp`4nSL29oj!(G?X2fV zAv3F?58A=(!!cUQKYySa7 C&Bjsy