Javascript Databases for offline storage

This new Javascript DB thing is fantastic. It allows one to open and store information offline, and local to the device that was accessing the website. The retrieval of the information is based on standard SQL. I have managed to create a website, as a playground for Javascript databases and i must say that i am pretty pleased. Some of the things that was tried in the simple project was:-

  1. Creating tables and dropping tables in a JS DB
  2. Inserting information into the DB.
  3. Inserting information as information is being retrieved from the internet. Effectively caching the information.
  4. Reading from the DB.
  5. Reading from the internet, but if any error occurs in the read, switch to the local database
  6. Complete sync of the server DB to the local DB. It will also check to see if the information already exist. If it exist, the information will not be re-inserted.
  7. Tracing of DB progress. As information are all called async, coming up with a way to know when the data is ready.
  8. Ability to calculate the transaction per second performance of the database.
  9. Toggling between online and offline states such that the application can behave differently.

I must say that all these things performed pretty well. However, the performance, IMHO is still lacking. On a desktop system, performance seems OK. But on a handheld, i believe more has to be done. Here are some tps information that i have managed to get using my own information. This is of course, not definitive.

To take a look at a sample application making use of Javascript Databases, go to http://himiko.dnsalias.net/ws/journal. Of course, it looks best on the iPhone.

Javascript DB

DB Size = 494KB
Records = 5812
String Columns = 2
ID Integer Column = 1

Performance in
iPhone simulator =~ 192 tps
Safari 3 =~ 214 tps
Safari Beta 4 =~ 303 tps
iPod Touch 1st Gen =~ 10 tps

Attached here is the test file that was used to beta the various Javascript DB functions before implementation. This should give a quick and dirty run down of what and how to do basic Javascript DBs.

Example Javascript Database