After migrating from 4.5.2 to 4.9.0, data loading is significantly slower

4.5.0
I === SQLCipher Configuration Analysis (Current Version) ===
I SQLCipher - cipher_memory_security: 0
I SQLCipher - cipher_page_size: 4096
I SQLCipher - cipher_hmac_algorithm: HMAC_SHA512
W SQLCipher - cipher_kdf_iter: No result
I SQLCipher - cipher_plaintext_header_size: 0
I SQLCipher - cipher_default_use_hmac: 1
I SQLCipher - synchronous: 2
I SQLCipher - journal_mode: delete
I SQLCipher - cache_size: -2000
I SQLCipher - temp_store: 0
I SQLCipher - mmap_size: 0
I SQLCipher - auto_vacuum: 0
I SQLCipher - page_size: 4096
I === End SQLCipher Configuration Analysis ===

4.9.0
I SQLCipher - cipher_memory_security: 0
I SQLCipher - cipher_page_size: 4096
I SQLCipher - cipher_hmac_algorithm: HMAC_SHA512
W SQLCipher - cipher_kdf_iter: No result
I SQLCipher - cipher_plaintext_header_size: 0
I SQLCipher - cipher_default_use_hmac: 1
I SQLCipher - synchronous: 1
I SQLCipher - journal_mode: delete
I SQLCipher - cache_size: -2000
I SQLCipher - temp_store: 0
I SQLCipher - mmap_size: 0
I SQLCipher - auto_vacuum: 0
I SQLCipher - page_size: 4096
I === End SQLCipher Configuration Analysis ===

How can I make it faster?

The difference is visible with a large database. With the old version, it takes 3 seconds to load, but after the update, it takes 1 minute.

Hello @Artavazd_Khachatryan - there isn’t enough information to go on here. Please provide details of what it means “to load” (i.e. what is the workload you are doing, queries, indexes etc), as well as what platform is involved. Generally 4.9.0 will perform better with 4.5.0 but there are always edge cases. Also make sure you have addressed all general performance guidelines:

Hi Stephen,

The platform is Android. I upgraded from net.zetetic:android-database-sqlcipher:4.5.2 to net.zetetic:sqlcipher-android:4.9.0, which also involved a repository change.

The scenario is simple: querying all data from a large table (~450,000 rows) and parsing it. For example, calling cursor.count was much faster on 4.5.2 than on 4.9.0.

The new SQLCipher for Android (sqlcipher-android) has different memory allocation behavior as of 4.7.0. It is possible that if you are querying a huge amount of data that you are running into performance issues due to reallocation. You might see some evidence of this in logcat output. The first thing to try is setting a preferred Cursor Window Size large enough to hold the content from your large query. Try something like this, which would set the Cursor Window Size to 8 GB.

 SQLiteCursor.setCursorWindowSize(8589934592);