ABCDEFGHIJKLMNOPQRSTUVWXYZ
1
NameDescription
2
Testing Repositoryhttps://github.com/bluelibs/bluelibs/tree/main/packages/nova/benchmarks/sql
3
Testing Architecture1 Database Server (t2.medium) MongoDB and PostgreSQL and another t2.medium server (which runs the benchmarks) in the same local network in eu-central-1 zone from AWS.
4
MethodologyWe designed a relational database composed of Posts, Comments, Users, Post Categories, Post Tags and User Groups which is designed in both MongoDB and SQL to match not only the data model and relationships but also contain the exact same dataset, then we started performing relational fetches (Nova vs SQL Joins etc)

Tests have been run 500 times each pass, and the result is their average for every query presented in there. You have measurements for individual queries so you can compare.

We wanted a fair comparison, this is why we chose a simple blog system, something that is real-life usage and easy to understand for someone wanting to understand the code, however Nova does have some points where it shines way more than SQL especially on very deeply nested relational queries. There's the inversed side also, SQL can be more performant than Nova for relational data in other given contexts. The results here are for one use-case only, the use-case was designed to fit reality not Mongo, not SQL.
5
What makes it so fast?Explained here: https://www.bluelibs.com/docs/package-nova#hypernova
6
InterpretationDue to the way relational data is fetched in SQL, JIT and propper coding, we've proven that the Nova driver for MongoDB is the fastest relational solution that is accessible very quickly.

Where Nova doesn't shine is when you perform complex relational filtering and sorting. While very capable of doing so, it lacks behind the speed of SQL which is designed to do such things. However, we still have pretty reasonable fast speeds and we still gain a lot by having at least 90% of the queries faster.
7
ConclusionsQ: Is it faster than SQL?
A: It's nuanced.

Our plan was to enhance MongoDB not necessarily reinvent SQL, we loved NoSQL for its sheer flexibility in the inception phase of our app, however we do not dismiss how great SQL databases have become. It all boils down to the right tool for the right job.
We would have been extremely happy just lagging around 25% from SQL speeds for fetching related data, we were surprised by the results too, as we did not expect such great improvements.
8
9
Click here to see the Analysis
10

PS: The deeper the query the faster Nova gets compared to SQL, it would be curious to compare it head-to-head to a 10-level deep query
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
99
100