[dojo-contributors] Gears/Storage performance issues

Aaron Boodman boogs at youngpup.net
Fri Aug 10 01:45:26 EDT 2007


Not just open close, but all updates to the database should happen in
a single transaction where possible for optimal performance.

So:

db.open("foo");
db.execute("BEGIN");
try {
  for (var i = 0; i < 100; i++) {
    db.execute("INSERT ...");
  }
  db.execute("COMMIT");
} catch (e) {
  db.execute("ROLLBACK");
} finally {
  db.close();
}

It is easy to wrap this sort of thing in a transact helper function.

function transact(fn) {
  db.open("foo");
  db.execute("BEGIN");
  try {
    fn();
    db.execute("COMMIT");
  } catch (e) {
    db.execute("ROLLBACK");
  } finally {
    db.close();
  }
}

- a

On 8/9/07, Brad Neuberg <paperairplane at gmail.com> wrote:
> Hi Adam. In terms of the performance issues for Dojo SQL, this is
> because every call to dojox.sql causes an automatic database
> open/close to happen to make it easier for developers. It is
> recommended that if you are doing a tight FOR loop like in that
> example that you point to that you manually open and close the
> database yourself; Dojo SQL will automatically see that you are taking
> things over and won't manage until you reclose it:
>
> dojox.sql.open();
> for(var i = 0; i < 1000; i++){
>    dojox.sql(/* Some SQL Statement in a loop */);
> }
> dojox.sql.close();
>
> For the performance issues for Flash, doing a bunch of
> dojox.storage.puts() is indeed an issue. One workaround is to simply
> save them all onto a single JavaScript object, and then do a
> dojox.storage.put on to that so you only have one call.
>
> I have moved away from primary maintenence of Dojo Flash Storage to
> focus on Dojo Offline using Google Gears and do not have the bandwidth
> to address issues related to it. If you have a proposal on how to
> modify the Dojo Storage put/get API for bulk puts and gets, and then
> craft a good patch to the Flash storage provider for 0.9 I would
> incorprate it if it looks clean enough in terms of the API. In general
> though I am looking for a new person to maintain patch management of
> Flash based storage in 0.9.
>
> Best,
>   Brad
>
> On 7/20/07, Adam L. Peller <adam at peller.org> wrote:
> > Hi Brad and Dylan.  Could I ask you to take a look at this thread:
> >
> > http://www.nabble.com/Dojo-Offline-and-SQLite-performance-tf4082361.html#a11713875
> >
> > There are continued requests for bulk getters and setters to overcome
> > a perceived performance problem.  For Flash, the issue is crossing the
> > native boundary.  In the case of SQL, it was suggested that database
> > open/close might be incurred for individual hits.
> >
> > Some of Julian's patches are getting stale in trac.  Since this could
> > impact the APIs, it would be great to deal with this "SRTL".
> >
> > Thanks,
> > Adam
> >
> _______________________________________________
> dojo-contributors mailing list
> dojo-contributors at dojotoolkit.org
> http://dojotoolkit.org/mailman/listinfo/dojo-contributors
>



More information about the dojo-contributors mailing list