Skip to content

Inserts are very slow on android 7.x with sqlcipher 4.0.1  #411

@mpelc87

Description

@mpelc87

Hi,

I have an issue with performance of sqlcipher 4.0.1 on Android 7.x
Inserts of big amounts of records in one transactions are ~10 times slower on sqlcipher 4.0.1 then on 3.5.9

Here is my sample app I'm using to measure performance:

`class MainActivity : AppCompatActivity() {
var database: SQLiteDatabase? = null

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    initSqlCipher()
    createSchema()
    insert()
}

fun initSqlCipher() {
    SQLiteDatabase.loadLibs(this)
    val databaseFile = getDatabasePath("demo.db")
    databaseFile.mkdirs()
    databaseFile.delete()

    database = SQLiteDatabase.openOrCreateDatabase(databaseFile, "test123", null)
}

private fun insert() {
    val startTime= System.currentTimeMillis()

    database?.execSQL("begin;")
    (1..10000).forEach {
        database?.execSQL("insert into some_table(name, surname) values(?, ?)",
            arrayOf<Any>("one for the money", "two for the show"))

    }
    database?.execSQL("commit;")

    Log.e("SchemaLog", "Inserted in: ${System.currentTimeMillis() - startTime} ms")
}

fun createSchema() {
    val startTime= System.currentTimeMillis()

    database?.execSQL("""CREATE TABLE some_table (
            name TEXT,
            surname TEXT)""".trimIndent())

    Log.e("SchemaLog", "Schema created in: ${System.currentTimeMillis() - startTime} ms")
}

}`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions