Chrome’s IndexedDB— from best in class to the slowest

Chrome has historically been the most stable and fast implementation of IndexedDB compared to the other browsers, but running some tests today tells a different story. It’s still the most stable (or 2nd most after Firefox) but the speed has fallen behind.

When I open Dexie’s simple performance fiddle, it looks like this in my Chrome:

And when I run the same on Safari:

Wow! 1 ms to find 99 documents and 21 ms to find almost 4000 matching docs!

And on Firefox:

Firefox is not that bad either! And unlike Safari, it isn’t slow in object deletions.

Now, this test puts random numbers into the indexed property, so it might not be 100% fare. So if I run the test 10 times on each browser and divide the querying time with the number of query results, it boils down to the following average results for each browser and test-part:

The tests were totally non-scientifically run on my laptop browser but at least 10 times each to get average results. But after writing down the results of each test in my spreadsheet, I noticed a slight slowdown on Chrome of query speed the more times I had run the test. I thought this could be due to some kind of index fragmentation so I couldn’t be 100% sure that database wasn’t more fragmented from start on my Chrome browser. So to be fair to Chrome, I gave Chrome some special care that the other browsers didn’t get: I deleted the database and re-ran the tests 10 times again to eliminate that possible unfairness. It made a difference! But still, Chrome is falling behind:

So, after recreating the database on Chrome to eliminate fragmentation causes, we get much better results, but still far away from how Safari and Firefox perform: 0.038 milliseconds per result row compared to 0.009 ms on Firefox and 0.005 ms on Safari. Still, I never measured how Safari or Firefox performed after database recreation — they might also perform better. But at least we know one thing: Safari and Firefox are way faster than Chrome in populating and querying IndexedDB.

Initial sync for offline applications

An offline-capable application will typically do large bulk-add operations on its initial sync. The time this take will affect usability for PWAs. In this use case, Safari outperforms the other browsers, Firefox is somewhere in the middle, Chrome is twice as slow as Firefox and 5 times as slow as Safari.

Summary

Chrome seems to have fallen behind both Firefox and Safari in IndexedDB querying speed and that:

Test environment

The tests were performed using this fiddle on my laptop.

Laptop configuration:

The versions of browsers were:

Chrome: Version 88.0.4324.192 (Official Build) (x86_64)
Safari: Version 14.0.3 (16610.4.3.1.4)
Firefox: 86.0 (64-bit)

Author of Dexie.js. Passionate about simplifying app development. Javascript. Isomorphic app, data fetching and React.