4

We integrate the SqlCiper sqlite db into our Android project. What we found out that there is some big difference of db query performance in unecrypted SqlCiper sqlite db and encrypted SqlCiper sqlite db.

We just did some basic timing logging at our code on same Android device:

  • unencrypted SqlCiper db: 100 db query, total time: 1-2 seconds
  • encrypted SqlCiper db: 100 db query, total time: 17 seconds.

As you could see that there is big increase in the running time when encryption is turned on in SqlCiper database.

Based on this post: SqlCiper Performance and SqlCiperSpeed, we won't see such big increase on iOS, however I didn't see any performance number on Android.

Do you guys see the same issues as we saw? Any suggestions to improve it?

windfly2006
  • 1,703
  • 3
  • 25
  • 48

2 Answers2

2

First, ensure that you have a problem worth worrying about. A query that takes 170ms, instead of 10ms, is unlikely to be a material difference to the user, in isolation. In either case, you need to be using a background thread, as even 10ms is enough to cause you to drop a frame or two, depending on what else is going on. Hence, if you are doing this query in response to some discrete user request (e.g., tapping on an action item), the user is unlikely to notice the difference. Only if you are doing a lot of these queries in a short time frame are you likely to have speed issues that might cause problems for the user.

Second, ensure that you have tuned your database access in general, using things like the EXPLAIN keyword. SQLCipher for Android makes poor database I/O worse, such as queries that result in table scans (e.g., due to not having the right indices).

Third, use Traceview to determine precisely where your time is being spent.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
2

You can optimized by the way:

1.In SQLCipher lib, used AES algorithm to encrypt data. --> You can change AES --> RC4. Performance increased 10-15%. (You can compared AES & RC4 before use it)

2.Important you shoud optimize data SQLite (create index, sql query,...); http://www.sqlite.org/optoverview.html

Huỳnh Ngọc Bang
  • 1,572
  • 1
  • 19
  • 22