-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Expand file tree
/
Copy pathIQP Demo - Row Mode MGF.sql
More file actions
42 lines (32 loc) · 1.01 KB
/
IQP Demo - Row Mode MGF.sql
File metadata and controls
42 lines (32 loc) · 1.01 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
-- ******************************************************** --
-- Row mode memory grant feedback
-- 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
-- SSMS v17.9 or higher
-- Email IntelligentQP@microsoft.com for questions\feedback
-- ******************************************************** --
USE [master];
GO
ALTER DATABASE [WideWorldImportersDW] SET COMPATIBILITY_LEVEL = 150;
GO
USE [WideWorldImportersDW];
GO
-- Simulate out-of-date stats
UPDATE STATISTICS Fact.OrderHistory
WITH ROWCOUNT = 1;
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,
si.[Lead Time Days]
FROM Fact.OrderHistory AS fo
INNER HASH JOIN Dimension.[Stock Item] AS si
ON fo.[Stock Item Key] = si.[Stock Item Key]
WHERE fo.[Lineage Key] = 9
AND si.[Lead Time Days] > 19;
-- Cleanup
UPDATE STATISTICS Fact.OrderHistory
WITH ROWCOUNT = 3702672;
GO