Adjust database parameters

This commit is contained in:
Jonas Lochmann 2022-03-07 01:00:00 +01:00
parent 7df677e777
commit d7d2f5eef3
No known key found for this signature in database
GPG key ID: 8B8C9AEE10FA5B36
2 changed files with 82 additions and 47 deletions

View file

@ -0,0 +1,26 @@
/*
* TimeLimit Copyright <C> 2019 - 2022 Jonas Lochmann
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package io.timelimit.android.data
import android.database.Cursor
fun Cursor.consume() {
this.use {
while (moveToNext()) {
// do nothing
}
}
}

View file

@ -1,5 +1,5 @@
/* /*
* TimeLimit Copyright <C> 2019 - 2021 Jonas Lochmann * TimeLimit Copyright <C> 2019 - 2022 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -21,6 +21,7 @@ import androidx.room.Database
import androidx.room.InvalidationTracker import androidx.room.InvalidationTracker
import androidx.room.Room import androidx.room.Room
import androidx.room.RoomDatabase import androidx.room.RoomDatabase
import androidx.sqlite.db.SupportSQLiteDatabase
import io.timelimit.android.async.Threads import io.timelimit.android.async.Threads
import io.timelimit.android.data.dao.DerivedDataDao import io.timelimit.android.data.dao.DerivedDataDao
import io.timelimit.android.data.invalidation.Observer import io.timelimit.android.data.invalidation.Observer
@ -125,6 +126,14 @@ abstract class RoomDatabase: RoomDatabase(), io.timelimit.android.data.Database
DatabaseMigrations.MIGRATE_TO_V38 DatabaseMigrations.MIGRATE_TO_V38
) )
.setQueryExecutor(Threads.database) .setQueryExecutor(Threads.database)
.addCallback(object: Callback() {
override fun onOpen(db: SupportSQLiteDatabase) {
super.onOpen(db)
db.query("PRAGMA journal_mode = PERSIST").consume()
db.query("PRAGMA journal_size_limit = 32768").consume()
}
})
.build() .build()
} }
} }