Performance Comparison of SQLite/OPFS versus WebSQL

The Performance Benchmark Program: speedtest1

The SQLite project has been using a performance measurement tool called "speedtest1" for many years. Speedtest1 runs a variety of SQL statements in an attempt to simulate a "typical" SQLite workload. Speedtest1 is the standard performance measurement tool for SQLite. It is used to generate graphs such the one near the top of

The default mode of operation for speedtest1 is for speedtest1 to invoke SQLite API routines directly. However, a run-time option can cause speedtest1 to emit pure SQL statements which can then be piped into a separate SQL execution engine to perform the tests. Speedtest1 also has a run-time option to control the "size" of the test, which changes both the size of the database and the number of queries executed against the database.

Two Ways Of Testing

  1. Direct execution means that the "speedtest1" program is run directly. Speedtest1 makes SQLite API calls to run the SQL statement.

  2. Script execution means that "speedtest1" is run with the --script option to generate a file that contains the (thousands) of SQL statements that would be run for a performance test, then that file of SQL statements is piped into the execution engine in order to run the test.

Due to design limitations, performance tests against WebSQL can only be run in script mode. In other words, to test the performance of WebSQL, we have to feed it a big script with thousands of SQL statements. The other variants of SQLite can all be run using either modality.

Variants Of SQLite Under Test

These are the different builds of SQLite that we compare:

Script-Mode Performance Comparisons

The following table shows approximate run-times (in milliseconds) for speedtest1 runs of various sizes in script mode.

SQL Statement Count WASM in-memory WebSQL WASMFS
14200 2200 2230 2240
71000 3050 4250 3400
177500 6200 6000 6900
355000 16000 10900 16350
710000 52000 40000 57200

Direct-Mode Performance Comparisons

The following table shows approximate run-times (in milliseconds) for running speedtest1 directly (compiled to WASM where appropriate).

SQL Statement Count C-native speedtest1 WASMFS sqlite3_vfs local/session storage
14200 40 245 270 150
71000 220 700 725 database too large
177500 540 1715 1620 database too large
355000 1230 3200 3200 database too large
710000 3200 6500 6700 database too large