File tree 3 files changed +78
-1
lines changed
3 files changed +78
-1
lines changed Original file line number Diff line number Diff line change 29
29
"test:sqlite" : " jest --config test/config/sqlite.json" ,
30
30
"test" : " yarn generate && yarn test:bigquery && yarn test:mysql && yarn test:sqlite" ,
31
31
"perf:big" : " yarn ts-node perf/perf-test.ts big" ,
32
- "perf:func" : " yarn ts-node perf/perf-test.ts func"
32
+ "perf:func" : " yarn ts-node perf/perf-test.ts func" ,
33
+ "perf:select" : " yarn ts-node perf/perf-test.ts select"
33
34
},
34
35
"devDependencies" : {
35
36
"@types/benchmark" : " ^2.1.2" ,
Original file line number Diff line number Diff line change
1
+ WITH
2
+ FullAlbum AS (
3
+ SELECT
4
+ AlbumId,
5
+ Album .Title AS AlbumName,
6
+ Artist .ArtistId AS ArtistId,
7
+ Artist .Name as ArtistName
8
+ FROM
9
+ Album
10
+ LEFT JOIN Artist ON Album .ArtistId = Artist .ArtistId
11
+ ),
12
+ FullTrack AS (
13
+ SELECT
14
+ TrackId,
15
+ Track .Name AS TrackName,
16
+ AlbumId,
17
+ MediaType .Name AS Media,
18
+ Genre .Name AS Genre,
19
+ Composer,
20
+ Milliseconds,
21
+ Bytes,
22
+ UnitPrice
23
+ FROM
24
+ Track
25
+ LEFT JOIN MediaType USING (MediaTypeId)
26
+ LEFT JOIN Genre USING (GenreId)
27
+ ),
28
+ ArtistTrackCount AS (
29
+ SELECT
30
+ ArtistId,
31
+ ArtistName,
32
+ COUNT (TrackId) AS TrackCount
33
+ FROM
34
+ FullAlbum
35
+ LEFT JOIN FullTrack USING (AlbumId)
36
+ GROUP BY
37
+ ArtistId
38
+ ORDER BY
39
+ TrackCount DESC ,
40
+ ArtistName ASC
41
+ ),
42
+ ArtistPlaylistCount AS (
43
+ SELECT
44
+ ArtistId,
45
+ ArtistName,
46
+ COUNT (DISTINCT PlaylistId) AS PlaylistCount
47
+ FROM
48
+ FullAlbum
49
+ LEFT JOIN Track USING (AlbumId)
50
+ LEFT JOIN PlaylistTrack USING (TrackId)
51
+ GROUP BY
52
+ ArtistId
53
+ ORDER BY
54
+ PlaylistCount DESC ,
55
+ ArtistName ASC
56
+ )
57
+ SELECT
58
+ ArtistTrackCount .ArtistName AS ArtistName,
59
+ TrackCount,
60
+ PlaylistCount,
61
+ TrackCount / PlaylistCount AS TracksPerPlaylist
62
+ FROM
63
+ ArtistTrackCount
64
+ LEFT JOIN ArtistPlaylistCount USING (ArtistId)
65
+ ORDER BY
66
+ TracksPerPlaylist DESC ,
67
+ TrackCount DESC ,
68
+ PlaylistCount DESC
69
+ LIMIT
70
+ 15 ;
Original file line number Diff line number Diff line change @@ -25,6 +25,12 @@ function createTestData(variant: string) {
25
25
mysql : getTestData ( "mysql" ) ,
26
26
bigquery : getTestData ( "bigquery" ) ,
27
27
} ;
28
+ } else if ( variant === "select" ) {
29
+ return {
30
+ sqlite : getTestData ( "select" ) ,
31
+ mysql : getTestData ( "select" ) ,
32
+ bigquery : getTestData ( "select" ) ,
33
+ } ;
28
34
} else {
29
35
throw new Error ( `Unknown test data variant: ${ variant } ` ) ;
30
36
}
You can’t perform that action at this time.
0 commit comments