forked from sergiisyrovatchenko/SQLSaturday
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path60 - stackoverflow 4Gb.sql
98 lines (75 loc) · 2.23 KB
/
60 - stackoverflow 4Gb.sql
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
Stack Exchange Data Dump: https://archive.org/details/stackexchange
December 15, 2016
sqloverflow.com-Badges.7zip
https://archive.org/download/stackexchange/stackoverflow.com-Badges.7z
Size: 2.26Gb
Rows: 20.758.501
sqloverflow.com-Users.7zip
https://archive.org/download/stackexchange/stackoverflow.com-Users.7z
Size: 1.81Gb
Rows: 6.438.658
*/
USE [master]
GO
IF DB_ID('StackOverflow') IS NOT NULL BEGIN
ALTER DATABASE StackOverflow SET SINGLE_USER WITH ROLLBACK IMMEDIATE
DROP DATABASE StackOverflow
END
GO
CREATE DATABASE StackOverflow
GO
ALTER DATABASE StackOverflow
ADD FILEGROUP InMemoryFG CONTAINS MEMORY_OPTIMIZED_DATA
GO
ALTER DATABASE StackOverflow
ADD FILE (NAME = InMemoryFile, FILENAME = N'X:\InMemory')
TO FILEGROUP InMemoryFG
GO
USE StackOverflow
GO
DROP TABLE IF EXISTS dbo.Badges
GO
CREATE TABLE dbo.Badges (
Id INT NOT NULL INDEX ix NONCLUSTERED
, UserId INT NOT NULL
, [Name] VARCHAR(100) NOT NULL
, [Date] DATETIME NOT NULL
, Class INT NOT NULL
, TagBased BIT NOT NULL
) WITH (MEMORY_OPTIMIZED = ON, DURABILITY = SCHEMA_ONLY)
GO
------------------------------------------------------
SET STATISTICS TIME ON
EXEC sys.xp_cmdshell 'CScript "D:\PROJECT\XML\SQLXMLBulkLoad\sample3.vbs"' -- Badges
SET STATISTICS TIME OFF
/*
SQL Server Execution Times:
CPU time = 0 ms, elapsed time = 349403 ms (5 min 49 sec)
*/
------------------------------------------------------
DROP TABLE IF EXISTS dbo.Users
GO
CREATE TABLE dbo.Users (
Id INT NOT NULL INDEX ix NONCLUSTERED
, Reputation INT NOT NULL
, CreationDate DATETIME NOT NULL
, DisplayName NVARCHAR(40)
, LastAccessDate DATETIME NOT NULL
, WebsiteUrl NVARCHAR(200)
, [Location] NVARCHAR(100)
, AboutMe NVARCHAR(MAX)
, [Views] INT NOT NULL
, UpVotes INT NOT NULL
, DownVotes INT NOT NULL
, Age INT
) WITH (MEMORY_OPTIMIZED = ON, DURABILITY = SCHEMA_ONLY)
GO
------------------------------------------------------
SET STATISTICS TIME ON
EXEC sys.xp_cmdshell 'CScript "D:\PROJECT\XML\SQLXMLBulkLoad\sample4.vbs"' -- Users
SET STATISTICS TIME OFF
/*
SQL Server Execution Times:
CPU time = 0 ms, elapsed time = 219970 ms (3 min 39 sec)
*/