SQLCipher (iOS) - Performance issues

Hello @Crabman - downloaded the sample project and ran it. I don’t have the same device, so instead tested on an iPhone X. A few comments:

  1. The tests I ran always used cipher_memory_security = OFF. The reason for this is that your test approaches a worst case scenario with respect to memory utilization and will certainly introduce massive overhead for memory sanitization. Repeatedly calling execute over and over causes redundant statement preparations equal to the number of iterations (see the related article linked below for another example of this same problem). A more memory efficient test would use prepared statements.
  2. I always created a new database for each test, to measure independently.

That said, when running the project on device, I found the timings of the runs comparable with or without encryption, e.g.

## without key
total time to insert 100000 items : 0.825302166 seconds
total time to insert 1000000 items : 8.900991291 seconds
## with key
total time to insert 100000 items : 1.057804541 seconds
total time to insert 1000000 items : 9.498042791 seconds

Dropping the SQLCipher pod entirely did result in a further time difference, with executions around 0.5 and 5 seconds respectively. However, that is still significantly less of a difference than you observed. There are a variety of potential reasons for that, e.g. further overhead related to inefficient tests, differences in test device performance, differences in the way CocoaPods is building the library vs the system SQLite, etc. From the first set of tests, however, it doesn’t seem like the issue is related to encryption, since that delta is within the expected range.

The related article: When performing transactions to insert data in batches, the efficiency of SQLcipher to insert data is much slower than that of sqlite - SQLCipher / SQLCipher FAQ - Zetetic Community Discussion