Skip to content

Commit 683ba68

Browse files
authored
Merge pull request #577 from microsoft/pmasl
Added EOS page
2 parents 5b68cea + b7d704e commit 683ba68

5 files changed

Lines changed: 278 additions & 262 deletions
Lines changed: 108 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,109 @@
1-
-- ***************************************************** --
2-
-- Purpose of this script: make WideWorldImportersDW
3-
-- bigger - so you can see more impactful
4-
-- Intelligent QP demonstrations (aka.ms/iqp)
5-
--
6-
-- Script last updated 05/03/2019
7-
--
8-
-- Database backup source: aka.ms/wwibak
9-
--
10-
-- Initial database file to restore before beginning this script:
11-
-- WideWorldImportersDW-Full.bak
12-
-- ***************************************************** --
13-
14-
USE WideWorldImportersDW;
15-
GO
16-
17-
/*
18-
Assumes a fresh restore of WideWorldImportersDW
19-
*/
20-
21-
IF OBJECT_ID('Fact.OrderHistory') IS NULL BEGIN
22-
SELECT [Order 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]
23-
INTO Fact.OrderHistory
24-
FROM Fact.[Order];
25-
END;
26-
27-
ALTER TABLE Fact.OrderHistory
28-
ADD CONSTRAINT PK_Fact_OrderHistory PRIMARY KEY NONCLUSTERED([Order Key] ASC, [Order Date Key] ASC)WITH(DATA_COMPRESSION=PAGE);
29-
GO
30-
31-
CREATE INDEX IX_Stock_Item_Key
32-
ON Fact.OrderHistory([Stock Item Key])
33-
INCLUDE(Quantity)
34-
WITH(DATA_COMPRESSION=PAGE);
35-
GO
36-
37-
CREATE INDEX IX_OrderHistory_Quantity
38-
ON Fact.OrderHistory([Quantity])
39-
INCLUDE([Order Key])
40-
WITH(DATA_COMPRESSION=PAGE);
41-
GO
42-
43-
/*
44-
Reality check... Starting count should be 231,412
45-
*/
46-
SELECT COUNT(*) FROM Fact.OrderHistory;
47-
GO
48-
49-
/*
50-
Make this table bigger (exec as desired)
51-
Notice the "GO 4"
52-
*/
53-
INSERT Fact.OrderHistory([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])
54-
SELECT [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]
55-
FROM Fact.OrderHistory;
56-
GO 4
57-
58-
/*
59-
Should be 3,702,592
60-
*/
61-
SELECT COUNT(*) FROM Fact.OrderHistory;
62-
GO
63-
64-
IF OBJECT_ID('Fact.OrderHistoryExtended') IS NULL BEGIN
65-
SELECT [Order 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]
66-
INTO Fact.OrderHistoryExtended
67-
FROM Fact.[OrderHistory];
68-
END;
69-
70-
ALTER TABLE Fact.OrderHistoryExtended
71-
ADD CONSTRAINT PK_Fact_OrderHistoryExtended PRIMARY KEY NONCLUSTERED([Order Key] ASC, [Order Date Key] ASC)
72-
WITH(DATA_COMPRESSION=PAGE);
73-
GO
74-
75-
CREATE INDEX IX_Stock_Item_Key
76-
ON Fact.OrderHistoryExtended([Stock Item Key])
77-
INCLUDE(Quantity);
78-
GO
79-
80-
/*
81-
Should be 3,702,592
82-
*/
83-
SELECT COUNT(*) FROM Fact.OrderHistoryExtended;
84-
GO
85-
86-
/*
87-
Make this table bigger (exec as desired)
88-
Notice the "GO 3"
89-
*/
90-
INSERT Fact.OrderHistoryExtended([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])
91-
SELECT [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]
92-
FROM Fact.OrderHistoryExtended;
93-
GO 3
94-
95-
/*
96-
Should be 29,620,736
97-
*/
98-
SELECT COUNT(*) FROM Fact.OrderHistoryExtended;
99-
GO
100-
101-
UPDATE Fact.OrderHistoryExtended
102-
SET [WWI Order ID] = [Order Key];
103-
GO
104-
105-
-- Repeat until log shrinks
106-
CHECKPOINT
107-
GO
108-
DBCC SHRINKFILE (N'WWI_Log' , 0, TRUNCATEONLY)
1+
-- ***************************************************** --
2+
-- Purpose of this script: make WideWorldImportersDW
3+
-- bigger - so you can see more impactful
4+
-- Intelligent QP demonstrations (aka.ms/iqp)
5+
--
6+
-- Script last updated 05/03/2019
7+
--
8+
-- Database backup source: aka.ms/wwibak
9+
--
10+
-- Initial database file to restore before beginning this script:
11+
-- WideWorldImportersDW-Full.bak
12+
-- ***************************************************** --
13+
14+
USE WideWorldImportersDW;
15+
GO
16+
17+
/*
18+
Assumes a fresh restore of WideWorldImportersDW
19+
*/
20+
21+
IF OBJECT_ID('Fact.OrderHistory') IS NULL BEGIN
22+
SELECT [Order 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]
23+
INTO Fact.OrderHistory
24+
FROM Fact.[Order];
25+
END;
26+
27+
ALTER TABLE Fact.OrderHistory
28+
ADD CONSTRAINT PK_Fact_OrderHistory PRIMARY KEY NONCLUSTERED([Order Key] ASC, [Order Date Key] ASC)WITH(DATA_COMPRESSION=PAGE);
29+
GO
30+
31+
CREATE INDEX IX_Stock_Item_Key
32+
ON Fact.OrderHistory([Stock Item Key])
33+
INCLUDE(Quantity)
34+
WITH(DATA_COMPRESSION=PAGE);
35+
GO
36+
37+
CREATE INDEX IX_OrderHistory_Quantity
38+
ON Fact.OrderHistory([Quantity])
39+
INCLUDE([Order Key])
40+
WITH(DATA_COMPRESSION=PAGE);
41+
GO
42+
43+
/*
44+
Reality check... Starting count should be 231,412
45+
*/
46+
SELECT COUNT(*) FROM Fact.OrderHistory;
47+
GO
48+
49+
/*
50+
Make this table bigger (exec as desired)
51+
Notice the "GO 4"
52+
*/
53+
INSERT Fact.OrderHistory([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])
54+
SELECT [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]
55+
FROM Fact.OrderHistory;
56+
GO 4
57+
58+
/*
59+
Should be 3,702,592
60+
*/
61+
SELECT COUNT(*) FROM Fact.OrderHistory;
62+
GO
63+
64+
IF OBJECT_ID('Fact.OrderHistoryExtended') IS NULL BEGIN
65+
SELECT [Order 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]
66+
INTO Fact.OrderHistoryExtended
67+
FROM Fact.[OrderHistory];
68+
END;
69+
70+
ALTER TABLE Fact.OrderHistoryExtended
71+
ADD CONSTRAINT PK_Fact_OrderHistoryExtended PRIMARY KEY NONCLUSTERED([Order Key] ASC, [Order Date Key] ASC)
72+
WITH(DATA_COMPRESSION=PAGE);
73+
GO
74+
75+
CREATE INDEX IX_Stock_Item_Key
76+
ON Fact.OrderHistoryExtended([Stock Item Key])
77+
INCLUDE(Quantity);
78+
GO
79+
80+
/*
81+
Should be 3,702,592
82+
*/
83+
SELECT COUNT(*) FROM Fact.OrderHistoryExtended;
84+
GO
85+
86+
/*
87+
Make this table bigger (exec as desired)
88+
Notice the "GO 3"
89+
*/
90+
INSERT Fact.OrderHistoryExtended([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])
91+
SELECT [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]
92+
FROM Fact.OrderHistoryExtended;
93+
GO 3
94+
95+
/*
96+
Should be 29,620,736
97+
*/
98+
SELECT COUNT(*) FROM Fact.OrderHistoryExtended;
99+
GO
100+
101+
UPDATE Fact.OrderHistoryExtended
102+
SET [WWI Order ID] = [Order Key];
103+
GO
104+
105+
-- Repeat until log shrinks
106+
CHECKPOINT
107+
GO
108+
DBCC SHRINKFILE (N'WWI_Log' , 0, TRUNCATEONLY)
109109
GO

samples/features/intelligent-query-processing/Intelligent QP Demos WideWorldImportersDW Public Preview - Interleaved Execution.sql

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
USE [WideWorldImportersDW];
1818
GO
1919

20-
CREATE FUNCTION [Fact].[WhatIfOutlierEventQuantity](@event VARCHAR(15), @beginOrderDateKey DATE, @endOrderDateKey DATE)
20+
CREATE OR ALTER FUNCTION [Fact].[ufn_WhatIfOutlierEventQuantity](@event VARCHAR(15), @beginOrderDateKey DATE, @endOrderDateKey DATE)
2121
RETURNS @OutlierEventQuantity TABLE (
2222
[Order Key] [bigint],
2323
[City Key] [int] NOT NULL,
@@ -122,10 +122,10 @@ GO
122122
USE [WideWorldImportersDW];
123123
GO
124124

125-
SELECT [fo].[Order Key], [fo].[Description], [fo].[Package],
125+
SELECT [fo].[Order Key], [fo].[Description], [fo].[Package],
126126
[fo].[Quantity], [foo].[OutlierEventQuantity]
127-
FROM [Fact].[Order] AS [fo]
128-
INNER JOIN [Fact].[WhatIfOutlierEventQuantity]('Mild Recession',
127+
FROM [Fact].[Order] AS [fo]
128+
INNER JOIN [Fact].[ufn_WhatIfOutlierEventQuantity]('Mild Recession',
129129
'1-01-2013',
130130
'10-15-2014') AS [foo] ON [fo].[Order Key] = [foo].[Order Key]
131131
AND [fo].[City Key] = [foo].[City Key]
@@ -137,7 +137,7 @@ INNER JOIN [Fact].[WhatIfOutlierEventQuantity]('Mild Recession',
137137
AND [fo].[Picker Key] = [foo].[Picker Key]
138138
INNER JOIN [Dimension].[Stock Item] AS [si]
139139
ON [fo].[Stock Item Key] = [si].[Stock Item Key]
140-
WHERE [si].[Lead Time Days] > 0
140+
WHERE [si].[Lead Time Days] > 0
141141
AND [fo].[Quantity] > 50;
142142
GO
143143

@@ -153,10 +153,10 @@ GO
153153
USE [WideWorldImportersDW];
154154
GO
155155

156-
SELECT [fo].[Order Key], [fo].[Description], [fo].[Package],
156+
SELECT [fo].[Order Key], [fo].[Description], [fo].[Package],
157157
[fo].[Quantity], [foo].[OutlierEventQuantity]
158-
FROM [Fact].[Order] AS [fo]
159-
INNER JOIN [Fact].[WhatIfOutlierEventQuantity]('Mild Recession',
158+
FROM [Fact].[Order] AS [fo]
159+
INNER JOIN [Fact].[ufn_WhatIfOutlierEventQuantity]('Mild Recession',
160160
'1-01-2013',
161161
'10-15-2014') AS [foo] ON [fo].[Order Key] = [foo].[Order Key]
162162
AND [fo].[City Key] = [foo].[City Key]
@@ -168,6 +168,6 @@ INNER JOIN [Fact].[WhatIfOutlierEventQuantity]('Mild Recession',
168168
AND [fo].[Picker Key] = [foo].[Picker Key]
169169
INNER JOIN [Dimension].[Stock Item] AS [si]
170170
ON [fo].[Stock Item Key] = [si].[Stock Item Key]
171-
WHERE [si].[Lead Time Days] > 0
171+
WHERE [si].[Lead Time Days] > 0
172172
AND [fo].[Quantity] > 50;
173173
GO

0 commit comments

Comments
 (0)