views:

456

answers:

3

Because of the lack of Unicode support on the embedded SQLite database in Android

I am mostly interested in performance and stability of H2 Database vs Android SQLite

Are you guys using it? Should I be aware of any H2 database shortcomings?

A: 

Might be interested by this post

Sephy
He is using a compressed database so the comparison is not a good one.
Eduardo
+1  A: 

I would be also very interested in real-world performance tests for the H2 database on Android. I think that H2 will be a lot slower than SQLite, mainly because the virtual machine on Android is still not that great. This got better with Android 2.2, but I think there is still a big difference. My guess is that H2 is currently about 10 times slower. But that's only a guess.

About the Unicode problem: what about converting strings to UTF-8 before storing them in SQLite?

Thomas Mueller
My problem is with functions like LOWER and UPPER that only work with ASCII characters because SQLite on Android does not have libicu linked in.
Eduardo
I know it's a pain, but what about storing an additional column with the 'uppercased' version of the data? So instead of CREATE TABLE ADDRESS(NAME VARCHAR(255)) you have CREATE TABLE ADDRESS(NAME VARCHAR(255), NAME_UPPER VARCHAR(255))
Thomas Mueller
@Thomas: You can just use TEXT columns; SQLite ignores VARCHAR lengths anyway.
Donal Fellows
For SQLite the data type TEXT is the same as VARCHAR, however for other databases it is different (TEXT usually means CLOB, which is stored externally, and is therefore slower - this includes H2). Both SQLite and H2 support defining columns as VARCHAR (without the length restriction), but most other databases need it, and some of them have a limit of 255 characters (I know it's weird).
Thomas Mueller
+1  A: 

Things are much better than I have expected. I now have an Android phone (HTC Desire, Android 2.2) and I made a first test.

Opening and closing a database is relatively slow so far (opening an existing database for the second time takes 0.2 seconds, closing about 0.2 seconds), but otherwise it looks like H2 performs quite well on Android, even if the Dalvik VM is not yet as optimized as a desktop JVM. It's too early to give concrete numbers, but Android is now a supported platform.

Thomas Mueller