SQLite in AIR – Slow writes

143467379_edcdc8a5d5.jpg

Just a quick note on SQLite in AIR and slow writes: using transactions will speed up multiple inserts/updates.

haven’t had a chance to do any performance tuning or testing when using SQLite in AIR.  But just today I finished writing some tests for writing some stuff into a SQL db and noticed that the writes were slow.  I created a little benchmark test project that wrote 55 records total over two tables with a  total of 4 columns of NUMERIC type for each table … nothing fancy.   This is obviously not a thorough analysis and just something quick and dirty, but just writing those 55 records took almost 30 seconds on average.  That’s way too slow.  Specially since I am not using any of the async methods, such a slow write speed will lock up your Flex interface.

Once I wrapped the saves in one transaction the speed went down to an average .4 seconds because the data is committed in one big chunk when you call commit.

There may be other ways to increase the speed. I’ll have to investigate this later. .4 seconds will probably still be too noticeable a hiccup on the interface so I’ll be changing my data store to use async methods.

Just thought I’d put it out there.

Also, if you have an table with an INTEGER PRIMARY KEY AUTOINCREMENT and you keep getting an error that says “Unable to convert Text value to Numeric value” or something to that effect make sure you’ve upgraded to the engineering drop of FB3 from January 14th, 2008.  Apparently that’s a bug in the version before that, but I didn’t find it on the Adobe bug db.

No Trackbacks

You can leave a trackback using this URL: http://machine501.com/blog/2008/01/29/sqlite-in-air-slow-writes/trackback/

2 Comments

  1. I have created a 15 table SQLite db to use with an AIR app my company has. I have to run in sychronous mode due to the way the app has to parse through a multi-tiered XML data file. I am wondering how you go about ‘wrapping the saves in one transaction’ as you mention here and speed up things without using asynchronous methds. Thanks.

    -Kurt Strinkorb

    Posted December 4, 2008 at 12:30 pm | Permalink
  2. This is an excellent tip which really helps improve the application and also allow me to avoid the horrible async database model of Air. Thank you.

    Posted March 26, 2009 at 5:17 pm | Permalink

Post a Comment

Your email is never shared. Required fields are marked *

*
*