SQL Performance in Android 4.0

With today’s advent of the Android 4.0.3 image for the Nexus S, we did some performance measurements. We wanted to test how Android 4.0 influences the speed of SQL/ORM operations in comparison to the previous version 2.3 on the same hardware. The results were surprising:

The chart shows that while loading entities got around 40% faster, inserting and updating data runs at half speed only compared to the older version! We expected overall better results because of the more optimized Dalvik VM (despite SQLite is a native library, the Java API imposes an significant overhead). However, the update and insert results hint at major changes in SQLite itself or the file system. We’ll keep you updated, as soon we find out more.

Update: If you want to check the benchmarking code, you should clone the greenDAO repository. The significant class for the benchmark is PerformanceTest. Here you have to comment some lines in again to activate the performance tests. Those are: runTests(1000); (6x) and runBatchTests(list);. It’s an abstract class, so you have to run X as an Android JUnit TestCase to start the benchmark. You will see the performance measurements in LogCat.

Posted in News and tagged , , , , .


  1. Running “adb shell cat /proc/mounts” shows:
    /dev/block/mtdblock4 /cache yaffs2 rw,nosuid,nodev,relatime 0 0
    /dev/block/mtdblock6 /efs yaffs2 rw,nosuid,nodev,noatime 0 0
    /dev/block/platform/s3c-sdhci.0/by-name/system /system ext4 ro,relatime,barrier=1,data=ordered 0 0
    /dev/block/platform/s3c-sdhci.0/by-name/userdata /data ext4 rw,nosuid,nodev,noatime,barrier=1,nomblk_io_submit,data=ordered 0 0

  2. There are custom kernels that improve SQL performance.. but I dont know what the tweak is explicitly. Modaco is one of those kernels.

  3. Just checked “adb shell cat /proc/mounts” on a Nexus S that was not upgraded and is still on 2.3.6. The output is almost the same:
    /dev/block/mtdblock4 /cache yaffs2 rw,nosuid,nodev,relatime 0 0
    /dev/block/mtdblock6 /efs yaffs2 rw,nosuid,nodev,relatime 0 0
    /dev/block/platform/s3c-sdhci.0/by-name/system /system ext4 ro,relatime,barrier=1,data=ordered 0 0
    /dev/block/platform/s3c-sdhci.0/by-name/userdata /data ext4 rw,nosuid,nodev,noatime,barrier=1,data=ordered 0 0

    So no change of the file system. The /data partition was ext4 before, the only difference seems to be the nomblk_io_submit option in Android 4.0. I have still no idea of its meaning after some googling. My gut feeling is that this option won’t make a big difference. I’d rather bet on SQLite itself or, a maybe a little less likely, on the SQLite Java APIs of Android.

Comments are closed.