IndexedDB Performance and IndexedDB v/s WebSQL performance comparison
Asked Answered
S

1

10

WebSQL and IndexedDB are both DB API for accessing (CRUD) the underlying embedded database in the web browser. Which, if I am correct, is like SQL for accessing (CRUD) any client-server database like Oracle etc. (in many case support for both WebSQL and IndexedDB is available on same browser)

  1. So, does it mean that both WebSQL and IndexedDB are accessing (CRUD) the same underlying embedded database and if that it the case then it will have same performance on all web browsers!
  2. But I think that is not the case, so does it mean that a web browser will have more than one underlying embedded database? And why there should be 2 underlying embedded database in same browser?

And since WebSQL and IndexedDB are API's, so it means that it not entirely correct to say performance of WebSQL and IndexedDB (because they are more like query/access language), but it significantly depends upon the performance of underlying embedded database. And, as per Google, LevelDB is faster than SQLite

  1. Is it correct to say that significantly it is not the performance difference between WebSQL and IndexedDB, but performance of underlying embedded database?
  2. What are the underlying embedded database for IE, Chrome, Android browser? I couldn't find this information on web, has anybody found or compiled it ever?
Shallop answered 23/3, 2015 at 20:49 Comment(0)
I
22

To address your first question, WebSQL was never implemented in either Internet Explorer or Firefox (http://diveintohtml5.info/storage.html, http://caniuse.com/#feat=sql-storage). In terms of the "big browsers" that leaves Chrome and Safari, both born out of WebKit (although since v28 Chrome has been running on a fork from WebKit, called 'Blink'). In the past both these browsers used SQLite as the underlying database for both WebSQL and IndexedDb, but Chrome switched IndexedDb from SQLite to LevelDB.

To answer your second question, Chrome uses 2 different underlying database technologies:

WebSQL -> SQLite

IndexedDb -> LevelDB

I suspect they keep WebSQL as SQLite as they know it works. WebSQL is now deprecated and at some point it will be removed so why would they spend time porting it over to LevelDB.

In terms of performance between WebSQL / IndexedDb versus the performance of the underlying database, from experience on iOS Safari, both IndexedDb and WebSQL uses a SQLite database but they differ vastly in how the underlying database is constructed and how they perform. In my testing I found that WebSQL was twice as fast as doing 1000 simple database inserts compared with IndexedDb on Safari in iOS8.

In terms of your last question, I found this out:

For IE:

WebSQL -> Not supported

IndexedDB -> Extensible Storage Engine

For Firefox:

WebSQL -> Not supported

IndexedDB -> SQLite

For Safari:

WebSQL -> SQLite

IndexedDB -> SQLite

For Chrome:

WebSQL -> SQLite

IndexedDB -> LevelDB

(Sources: The WebKit project, https://bugzilla.mozilla.org/show_bug.cgi?id=837141, http://www.aaron-powell.com/posts/2012-10-05-indexeddb-storage.html)

Interpreter answered 24/3, 2015 at 19:53 Comment(9)
I agree with you about info on whether given browser supports WebSQL and IndexedDB or not. But I am not sure if Extensible Storage Engine is the underlying embedded database for IE. I went through the Wiki of Extensible Storage Engine and there is no mention about the same. Please correct me if I am wrong. It could be SQL Server Compact. As per your comment - but they differ vastly in how the underlying database is constructed and how they perform. Could you please throw light on this. You mean IndxedDB and WebSQL construct their own database in browser at runtime?Shallop
Based on the numerous articles I have read on the internet, IE does indeed use ESE as it's underlying storage engine. In particular, if you browse to your "C:\Users\%USER%\AppData\Local\Microsoft\Internet Explorer\Indexed DB" folder, you will see the files that IndexedDB creates. I also believe if you have access to a copy of the ESEUtil tool, you would be able to dump the contents of IndexedDb.Interpreter
In terms of my comment about IndexedDB and WebSQL being different, this comes from painful experience of trying to use IndexedDB and WebSQL on iOS8. Considering they both use SQLite underneath, WebSQL is twice as fast as IndexedDB. With IndexedDB and WebSQL, when you try to open a database, if the database does not exist then it gets created. The big difference between the 2 is that when you call openDatabase for WebSQL, you need to specify the maximum database size you want to create. You seem to be asking a lot of in-depth questions. What is it you really need to know?Interpreter
1. Ok. Have you came across reference of some official web page which can be trusted, I don't want to go with blog. I got to that path but still it doesn't prove ESE, right? 2. We are migrating from WebSQL to IndexedDB, so I want to understand from IndexedDB performance perspective that if there is really something which can be done while preparing implementation design and/or coding to improve the performance. My understanding till now is that if IndexedDB is implemented on top of WebSQL then it would be faster than on top of LevelDB. Don't know about ESE for IE.Shallop
As per my understanding since it entirely depends on how IndexedDB is implemented on the top of underlying embedded database, at best one can do to improve the performance is to use concept like bulk/batch insert and bulk/batch query. What do you think? Your recommendations or ideas?Shallop
Unfortunately, from my own experience, if your webapp is going to be run on iOS Safari, don't move it to IndexedDB. There are too many bugs in Apple's implementation of IndexedDB that migrating to it would introduce more problems than it would fix.Interpreter
"My understanding till now is that if IndexedDB is implemented on top of WebSQL ..." That is wrong. IndexedDB is not implemented on top of WebSQL. IndexedDB was introduced to replace WebSQL.Interpreter
Just as a side note, the utility I mentioned earlier was not ESEUtil, it is in fact esentutl.exe (Extensible Storage Engine Utilities). I don't know what else to say about ESE. Blog or official, IndexedDB on Internet Explorer uses an ESE database. Fact.Interpreter
Thanks for your inputs. If I will come across some official note than I will update in this thread, could you please do the same. For now I trust that its ESE. My bad - a typo on "My understanding till now is that if IndexedDB is implemented on top of WebSQL ..." :)Shallop

© 2022 - 2024 — McMap. All rights reserved.