Dexie.js: Is IndexedDB really this slow on Safari?

Created on 5 Mar 2017  路  10Comments  路  Source: dfahlander/Dexie.js

This is really just a question, not an issue in Dexie (I think).

Please see my answer on this post: http://stackoverflow.com/questions/41824512/indexeddb-has-bad-performance-on-ios/42604890#42604890

I've seen really terrible performance on Safari (iOS and desktop) when using bulkPut with more than 1000 records. It seems to take longer and longer PER RECORD the more records I pass to bulkPut.

Even the sample code on the bulkPut documentation page (http://dexie.org/docs/Table/Table.bulkPut()) doesn't really work on Safari. If I limit to 1000 records, it will return after a few seconds, but with 100,000 records as shown in the sample, it just hangs (I assume it would return eventually, but I haven't waited long enough.)

Is Safari's IndexedDB performance really this bad, or am I missing something? Is this an issue with Dexie or with IndexedDB itself? Is there any way around it? If it's an issue in Safari, should we have any hope that it will be improved soon?

Most helpful comment

Agreed that whatever you're seeing is very unlikely a spec issue.

Which version of Safari are you testing with?

Newest Safari Technology Preview has significant performance improvements over Safari 10, but we've only improved what we know about; If nobody has filed a WebKit bug or reached out to me directly about a particular issue it's very possible we don't know about it.

I'd urge you to test whatever it is you're noticing on latest STP, the latest macOS 10.12.4 beta, or the latest iOS 10.3 beta.

If you're still seeing issues, please file a bug at bugs.webkit.org.

All 10 comments

I know Apple has been working hard for improving indexedDB on Safari during the last year. The versions have improved incredibly for each new minor version. Which version are you testing? Maybe @beidson knows whether performance fixes have been looked at to?

Agreed that whatever you're seeing is very unlikely a spec issue.

Which version of Safari are you testing with?

Newest Safari Technology Preview has significant performance improvements over Safari 10, but we've only improved what we know about; If nobody has filed a WebKit bug or reached out to me directly about a particular issue it's very possible we don't know about it.

I'd urge you to test whatever it is you're noticing on latest STP, the latest macOS 10.12.4 beta, or the latest iOS 10.3 beta.

If you're still seeing issues, please file a bug at bugs.webkit.org.

Yup. It's a whole lot faster in the beta Safari. Good work. (Haven't checked out iOS beta yet)

This has still been a persistent issue for us even with the latest versions of iOS and Safari, performance is far worse than compared to Chrome on the desktop and Android.

One detail I've just come across is the case insensitive operators (equalsIgnoreCase, startWithIgnoreCase, etc) are really slow on safari, it almost seems like it's doing an unindexed query behind the scenes. Reworking things to use the case sensitive versions is an order of magnitude faster in many of the cases I'm working with.

This isn't fixing all of our performance issues (anyOf queries for large datasets are still really slow for us as well), but it's a noticeable improvement

Thanks for trying things out in Safari!

To reiterate my comment from over a year ago, reporting general perf issues in one browser in a spec issue probably won't help accomplish anything.

I encourage you to file a bug at bugs.webkit.org with a test case for the issue you're seeing. (Or, multiple bugs, each with a different test case if you're seeing clearly different issues)

We can't fix what we don't know about.

Yeah, I wasn't expecting anything to be fixed in Dexie as a result of my comment, it was more a matter of throwing in my 2c in case anyone else is running into similar issues using case insensitive queries.

Given how responsive Apple is in general addressing issues like this I'll probably just spend my time working around how it behaves as-is...

Given how responsive Apple is in general addressing issues like this I'll probably just spend my time working around how it behaves as-is...

You're speaking to the engineer who re-wrote the IDB that's currently shipping in Safari, including fixing many perf issues reported by Dexie users and users of other frameworks.

I'm telling you directly I'm interesting in investigating the perf issues you're seeing.

If you still don't report them... That's simply too bad.

Fair enough, I apologize for being flippant in that case.

If I have some free time on a weekend or something I'll see if I can generate some isolated reproduction cases. Part of the problem is it needs to be fairly complex to run across noticeable issues in the first place, so those tend to be a lot harder to come up with standalone reproduction cases. At least there are things like Dexie and idb that make the underlying API somewhat palatable.

@beidson @MattKunze here is a jsfiddle that demonstrates the issue.
https://fiddle.jshell.net/dfahlander/xf2zrL4p/show
https://jsfiddle.net/dfahlander/xf2zrL4p/
On safari you'll have to click the link in the Result window to launch without iframe.

Put operations are consistently faster than chrome :)
Delete operations are brutally slow :( :( :(

__________Results on Safari____________

Using Dexie v2.0.4

bulkPut()

Let's put 10,000 documents into indexedDB! ...
Put operations done. Took 789 milliseconds.

Query

Now query all documents within a small range...
Took 10 milliseconds to find 120 matching documents
Now query all documents within a large range...
Took 114 milliseconds to find 3985 matching documents

Deleting

Now deleting all documents...
Delete operaton done. Took 6771 milliseconds.
All Done.

___________Results on Chrome (same macbook pro)____________

Using Dexie v2.0.4

bulkPut()

Let's put 10,000 documents into indexedDB! ...
Put operations done. Took 1107 milliseconds.

Query

Now query all documents within a small range...
Took 21 milliseconds to find 88 matching documents
Now query all documents within a large range...
Took 99 milliseconds to find 3996 matching documents

Deleting

Now deleting all documents...
Delete operaton done. Took 85 milliseconds.
All Done.

@beidson

Here is an edited fiddle of the one above that just does bulk put/deletes in IndexedDB directly
https://jsfiddle.net/pzur4mtb/3/

On Chrome (Desktop):

Database initialised

bulkPut()
10000 PUT operations queued in 1715ms

bulkDelete()
10000 DELETE operations queued in 680ms

Put Transaction completed in 2764ms.
Delete Transaction completed in 2427ms.

On Safari (iOS 12):

Database initialised

bulkPut()
10000 PUT operations queued in 193ms

bulkDelete()
10000 DELETE operations queued in 50ms

Put Transaction completed in 2800ms.
Delete Transaction completed in 42039ms.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dfahlander picture dfahlander  路  16Comments

abieri picture abieri  路  15Comments

carlos00027 picture carlos00027  路  14Comments

peterbe picture peterbe  路  12Comments

PalmerAL picture PalmerAL  路  12Comments