-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Expand file tree
/
Copy pathIQP Demo - Batch Mode on Rowstore.sql
More file actions
54 lines (45 loc) · 1.28 KB
/
IQP Demo - Batch Mode on Rowstore.sql
File metadata and controls
54 lines (45 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
-- ******************************************************** --
-- 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
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);