|
1 | | --- ******************************************************** -- |
2 | | --- Table variable deferred compilation |
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 Public Preview and works in Azure SQL DB too |
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 | | -DECLARE @Order TABLE |
26 | | - ([Order Key] BIGINT NOT NULL, |
27 | | - [Quantity] INT NOT NULL |
28 | | - ); |
29 | | - |
30 | | -INSERT @Order |
31 | | -SELECT [Order Key], [Quantity] |
32 | | -FROM [Fact].[OrderHistory] |
33 | | -WHERE [Quantity] > 1; |
34 | | - |
35 | | --- Look at estimated rows, speed, join algorithm |
36 | | -SELECT oh.[Order Key], oh.[Order Date Key], |
37 | | - oh.[Unit Price], o.Quantity |
38 | | -FROM Fact.OrderHistoryExtended AS oh |
39 | | -INNER JOIN @Order AS o |
40 | | - ON o.[Order Key] = oh.[Order Key] |
41 | | -WHERE oh.[Unit Price] > 0.10 |
42 | | -ORDER BY oh.[Unit Price] DESC; |
43 | | -GO |
44 | | - |
45 | | -USE [master] |
46 | | -GO |
47 | | - |
48 | | -ALTER DATABASE [WideWorldImportersDW] SET COMPATIBILITY_LEVEL = 150 |
49 | | -GO |
50 | | - |
51 | | -USE [WideWorldImportersDW] |
52 | | -GO |
53 | | - |
54 | | -DECLARE @Order TABLE |
55 | | - ([Order Key] BIGINT NOT NULL, |
56 | | - [Quantity] INT NOT NULL |
57 | | - ); |
58 | | - |
59 | | -INSERT @Order |
60 | | -SELECT [Order Key], [Quantity] |
61 | | -FROM [Fact].[OrderHistory] |
62 | | -WHERE [Quantity] > 99; |
63 | | - |
64 | | --- Look at estimated rows, speed, join algorithm |
65 | | -SELECT oh.[Order Key], oh.[Order Date Key], |
66 | | - oh.[Unit Price], o.Quantity |
67 | | -FROM Fact.OrderHistoryExtended AS oh |
68 | | -INNER JOIN @Order AS o |
69 | | - ON o.[Order Key] = oh.[Order Key] |
70 | | -WHERE oh.[Unit Price] > 0.10 |
71 | | -ORDER BY oh.[Unit Price] DESC; |
72 | | -GO |
73 | | - |
| 1 | +-- ******************************************************** -- |
| 2 | +-- Table variable deferred compilation |
| 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 Public Preview and works in Azure SQL DB too |
| 9 | + |
| 10 | +-- Email IntelligentQP@microsoft.com for questions\feedback |
| 11 | +-- ******************************************************** -- |
| 12 | + |
| 13 | +USE [master]; |
| 14 | +GO |
| 15 | + |
| 16 | +ALTER DATABASE [WideWorldImportersDW] SET COMPATIBILITY_LEVEL = 140; |
| 17 | +GO |
| 18 | + |
| 19 | +ALTER DATABASE SCOPED CONFIGURATION CLEAR PROCEDURE_CACHE; |
| 20 | +GO |
| 21 | + |
| 22 | +USE [WideWorldImportersDW]; |
| 23 | +GO |
| 24 | + |
| 25 | +DECLARE @Order TABLE |
| 26 | + ([Order Key] BIGINT NOT NULL, |
| 27 | + [Quantity] INT NOT NULL |
| 28 | + ); |
| 29 | + |
| 30 | +INSERT @Order |
| 31 | +SELECT [Order Key], [Quantity] |
| 32 | +FROM [Fact].[OrderHistory] |
| 33 | +WHERE [Quantity] > 99; |
| 34 | + |
| 35 | +-- Look at estimated rows, speed, join algorithm |
| 36 | +SELECT oh.[Order Key], oh.[Order Date Key], |
| 37 | + oh.[Unit Price], o.Quantity |
| 38 | +FROM Fact.OrderHistoryExtended AS oh |
| 39 | +INNER JOIN @Order AS o |
| 40 | + ON o.[Order Key] = oh.[Order Key] |
| 41 | +WHERE oh.[Unit Price] > 0.10 |
| 42 | +ORDER BY oh.[Unit Price] DESC; |
| 43 | +GO |
| 44 | + |
| 45 | +USE [master] |
| 46 | +GO |
| 47 | + |
| 48 | +ALTER DATABASE [WideWorldImportersDW] SET COMPATIBILITY_LEVEL = 150 |
| 49 | +GO |
| 50 | + |
| 51 | +USE [WideWorldImportersDW] |
| 52 | +GO |
| 53 | + |
| 54 | +DECLARE @Order TABLE |
| 55 | + ([Order Key] BIGINT NOT NULL, |
| 56 | + [Quantity] INT NOT NULL |
| 57 | + ); |
| 58 | + |
| 59 | +INSERT @Order |
| 60 | +SELECT [Order Key], [Quantity] |
| 61 | +FROM [Fact].[OrderHistory] |
| 62 | +WHERE [Quantity] > 99; |
| 63 | + |
| 64 | +-- Look at estimated rows, speed, join algorithm |
| 65 | +SELECT oh.[Order Key], oh.[Order Date Key], |
| 66 | + oh.[Unit Price], o.Quantity |
| 67 | +FROM Fact.OrderHistoryExtended AS oh |
| 68 | +INNER JOIN @Order AS o |
| 69 | + ON o.[Order Key] = oh.[Order Key] |
| 70 | +WHERE oh.[Unit Price] > 0.10 |
| 71 | +ORDER BY oh.[Unit Price] DESC; |
| 72 | +GO |
| 73 | + |
0 commit comments