-
Notifications
You must be signed in to change notification settings - Fork 5
/
load_data.sql
90 lines (86 loc) · 3.41 KB
/
load_data.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
--Set password for postgres user.
--We need this later.
ALTER USER postgres WITH PASSWORD 'pass';
--Create tables for different size tables
CREATE TABLE data_10 (
nconst bigint,
primaryName text,
birthYear bigint,
deathYear bigint,
primaryProfession text,
knownForTitles text
);
CREATE TABLE data_11 (
nconst bigint,
primaryName text,
birthYear bigint,
deathYear bigint,
primaryProfession text,
knownForTitles text
);
CREATE TABLE data_12 (
nconst bigint,
primaryName text,
birthYear bigint,
deathYear bigint,
primaryProfession text,
knownForTitles text
);
CREATE TABLE data_13 (
nconst bigint,
primaryName text,
birthYear bigint,
deathYear bigint,
primaryProfession text,
knownForTitles text
);
CREATE TABLE data_14 (
nconst bigint,
primaryName text,
birthYear bigint,
deathYear bigint,
primaryProfession text,
knownForTitles text
);
CREATE TABLE data_15 (
nconst bigint,
primaryName text,
birthYear bigint,
deathYear bigint,
primaryProfession text,
knownForTitles text
);
CREATE TABLE data_16 (
nconst bigint,
primaryName text,
birthYear bigint,
deathYear bigint,
primaryProfession text,
knownForTitles text
);
CREATE TABLE data_all (
nconst bigint,
primaryName text,
birthYear bigint,
deathYear bigint,
primaryProfession text,
knownForTitles text
);
--Load the 69420 table from the IMDB dataset sample.
copy data_all from '/data/sample_imdb.tsv';
--Create smaller tables and store them locally
COPY (SELECT * FROM data_all ORDER BY nconst ASC LIMIT 1024 ) TO '/tmp/data_10.tsv';
COPY (SELECT * FROM data_all ORDER BY nconst ASC LIMIT 2048 ) TO '/tmp/data_11.tsv';
COPY (SELECT * FROM data_all ORDER BY nconst ASC LIMIT 4196 ) TO '/tmp/data_12.tsv';
COPY (SELECT * FROM data_all ORDER BY nconst ASC LIMIT 8192 ) TO '/tmp/data_13.tsv';
COPY (SELECT * FROM data_all ORDER BY nconst ASC LIMIT 16384 ) TO '/tmp/data_14.tsv';
COPY (SELECT * FROM data_all ORDER BY nconst ASC LIMIT 32768 ) TO '/tmp/data_15.tsv';
COPY (SELECT * FROM data_all ORDER BY nconst ASC LIMIT 65536 ) TO '/tmp/data_16.tsv';
--Load table data from tables create above
copy data_10 from '/tmp/data_10.tsv';
copy data_11 from '/tmp/data_11.tsv';
copy data_12 from '/tmp/data_12.tsv';
copy data_13 from '/tmp/data_13.tsv';
copy data_14 from '/tmp/data_14.tsv';
copy data_15 from '/tmp/data_15.tsv';
copy data_16 from '/tmp/data_16.tsv';