Benchmarks
January 8, 2025 ยท View on GitHub
Table of Contents
Overview
- :warning: This benchmark is an initial version and it can certainly be greatly improved to make the results as relevant as possible. Feel free to open issues to improve it.
- :point_right: Native DB will be further improved in the future as performance issues have not yet been addressed. That is indeed the purpose of this benchmark, which is to provide visibility on what needs to be improved.
Comparison between Native DB vs Redb vs SQLite
- Why compare with
Redb?- To highlight the
Native DBoverhead, becauseRedbis the backend ofNative DB, it should "normally" always be faster thanNative DB.
- To highlight the
- Why compare with
SQLite?- Because even though
SQLiteoffers a lot more options,Native DBcan be seen as a very light alternative toSQLite.
- Because even though
- And the other databases?
- Knowing the capabilities of
Native DBcompared toRedbwith the benchmark below, you can check the benchmark of redb here: cberner/redb/benchmarks
- Knowing the capabilities of
The benchmarks ignore:
native_modeloverhead.- Serialization overhead used by
native_modellikebincode,postcardetc. - The fact that
redbcan write the data using zero-copy.
Explanation:
1:SK,10:SK,50:SK,100:SK,N:SKin this caseNis the number of secondary keys (SK) for the same data. Regarding SQLite, it is the column with each having a secondary index.1:T,n:Trepresent the number of operations per transaction.1:Tmeans one operation per transaction, for example, for insertion, it means there is only one insert operation per transaction.n:Tmeansnoperations per transaction,nis defined bycriterion, meaning that all operations are within a single transaction.
- We can see that
Redbsometimes has no comparisons (N/A) becauseRedbis a key-value database and does not support secondary indexes. Therefore, it is pointless to compare with more or fewer secondary indexes.
Benchmark Results
Insert
Native_db | Native_db_twophasecommit | Native_db_quickrepair | Redb | Sqlite | |
|---|---|---|---|---|---|
1:SK with n:T | 5.36 us (โ
1.00x) | 5.42 us (โ
1.01x slower) | 5.37 us (โ
1.00x slower) | 1.09 us (๐ 4.90x faster) | 1.68 us (๐ 3.19x faster) |
1:SK with 1:T | 33.43 us (โ
1.00x) | 428.91 us (โ 12.83x slower) | 33.31 us (โ
1.00x faster) | 15.66 us (๐ 2.13x faster) | 47.86 us (โ 1.43x slower) |
10:SK with n:T | 31.21 us (โ
1.00x) | 31.36 us (โ
1.00x slower) | 31.08 us (โ
1.00x faster) | N/A | 3.38 us (๐ 9.25x faster) |
10:SK with 1:T | 136.49 us (โ
1.00x) | 525.33 us (โ 3.85x slower) | 139.00 us (โ
1.02x slower) | N/A | 50.10 us (๐ 2.72x faster) |
50:SK with n:T | 149.93 us (โ
1.00x) | 149.58 us (โ
1.00x faster) | 148.39 us (โ
1.01x faster) | N/A | 16.35 us (๐ 9.17x faster) |
50:SK with 1:T | 537.67 us (โ
1.00x) | 899.42 us (โ 1.67x slower) | 539.79 us (โ
1.00x slower) | N/A | 66.48 us (๐ 8.09x faster) |
100:SK with n:T | 294.09 us (โ
1.00x) | 291.53 us (โ
1.01x faster) | 291.70 us (โ
1.01x faster) | N/A | 44.57 us (๐ 6.60x faster) |
100:SK with 1:T | 916.36 us (โ
1.00x) | 1.23 ms (โ 1.34x slower) | 923.44 us (โ
1.01x slower) | N/A | 98.20 us (๐ 9.33x faster) |
Get
Native_db | Native_db_twophasecommit | Native_db_quickrepair | Redb | Sqlite | |
|---|---|---|---|---|---|
1:SK | 960.70 ns (โ
1.00x) | 960.34 ns (โ
1.00x faster) | 957.75 ns (โ
1.00x faster) | 492.15 ns (๐ 1.95x faster) | 1.99 us (โ 2.07x slower) |
10:SK | 2.49 us (โ
1.00x) | 2.50 us (โ
1.00x slower) | 2.50 us (โ
1.01x slower) | N/A | 3.34 us (โ 1.34x slower) |
50:SK | 113.49 us (โ
1.00x) | 112.27 us (โ
1.01x faster) | 114.37 us (โ
1.01x slower) | N/A | 21.13 us (๐ 5.37x faster) |
100:SK | 241.06 us (โ
1.00x) | 265.73 us (โ
1.10x slower) | 246.91 us (โ
1.02x slower) | N/A | 49.21 us (๐ 4.90x faster) |
Select Range Secondary Key
Native_db | Native_db_twophasecommit | Native_db_quickrepair | Sqlite | |
|---|---|---|---|---|
1:SK value range | 1.88 ms (โ
1.00x) | 1.88 ms (โ
1.00x faster) | 1.91 ms (โ
1.02x slower) | 706.00 us (๐ 2.66x faster) |
10:SK value range | 2.10 ms (โ
1.00x) | 2.06 ms (โ
1.02x faster) | 2.06 ms (โ
1.02x faster) | 1.35 ms (โ
1.55x faster) |
50:SK value range | 5.02 ms (โ
1.00x) | 4.65 ms (โ
1.08x faster) | 4.66 ms (โ
1.08x faster) | 4.64 ms (โ
1.08x faster) |
100:SK value range | 6.99 ms (โ
1.00x) | 7.02 ms (โ
1.00x slower) | 6.92 ms (โ
1.01x faster) | 8.55 ms (โ 1.22x slower) |
1:SK random range | 1.90 ms (โ
1.00x) | 1.87 ms (โ
1.01x faster) | 1.92 ms (โ
1.01x slower) | 758.63 us (๐ 2.50x faster) |
10:SK random range | 2.15 ms (โ
1.00x) | 2.06 ms (โ
1.04x faster) | 2.10 ms (โ
1.02x faster) | 1.37 ms (โ
1.56x faster) |
50:SK random range | 4.43 ms (โ
1.00x) | 4.32 ms (โ
1.03x faster) | 4.30 ms (โ
1.03x faster) | 4.89 ms (โ
1.10x slower) |
100:SK random range | 5.47 ms (โ
1.00x) | 8.25 ms (โ 1.51x slower) | 6.21 ms (โ 1.14x slower) | 9.80 ms (โ 1.79x slower) |
Delete
:warning: We can see that when all operations are in a single transaction (n:T), Native DB has a huge overhead. An issue has been created to resolve this problem #256.
Native_db | Native_db_twophasecommit | Native_db_quickrepair | Redb | Sqlite | |
|---|---|---|---|---|---|
1:SK with n:T | 6.00 us (โ
1.00x) | 5.99 us (โ
1.00x faster) | 6.07 us (โ
1.01x slower) | 1.15 us (๐ 5.22x faster) | 1.23 us (๐ 4.90x faster) |
1:SK with 1:T | 30.76 us (โ
1.00x) | 30.75 us (โ
1.00x faster) | 31.38 us (โ
1.02x slower) | 14.65 us (๐ 2.10x faster) | 46.96 us (โ 1.53x slower) |
10:SK with n:T | 36.93 us (โ
1.00x) | 37.24 us (โ
1.01x slower) | 37.18 us (โ
1.01x slower) | N/A | 1.39 us (๐ 26.60x faster) |
10:SK with 1:T | 129.28 us (โ
1.00x) | 127.75 us (โ
1.01x faster) | 131.43 us (โ
1.02x slower) | N/A | 47.85 us (๐ 2.70x faster) |
50:SK with n:T | 176.44 us (โ
1.00x) | 174.57 us (โ
1.01x faster) | 177.47 us (โ
1.01x slower) | N/A | 1.79 us (๐ 98.42x faster) |
50:SK with 1:T | 501.98 us (โ
1.00x) | 501.80 us (โ
1.00x faster) | 501.82 us (โ
1.00x faster) | N/A | 51.22 us (๐ 9.80x faster) |
100:SK with n:T | 349.38 us (โ
1.00x) | 350.17 us (โ
1.00x slower) | 349.73 us (โ
1.00x slower) | N/A | 2.36 us (๐ 148.25x faster) |
100:SK with 1:T | 862.53 us (โ
1.00x) | 841.21 us (โ
1.03x faster) | 851.42 us (โ
1.01x faster) | N/A | 54.53 us (๐ 15.82x faster) |
Made with criterion-table