From f0b6fa622c156747219a9328ea85ab8eedd41eed Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Sat, 27 Dec 2025 12:11:58 -0500 Subject: [PATCH] adds vacuum and analyse utility functions --- .../nip01Core/store/sqlite/SQLiteEventStore.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/SQLiteEventStore.kt b/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/SQLiteEventStore.kt index a999c6f84..20bb2bfea 100644 --- a/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/SQLiteEventStore.kt +++ b/quartz/src/androidMain/kotlin/com/vitorpamplona/quartz/nip01Core/store/sqlite/SQLiteEventStore.kt @@ -116,6 +116,18 @@ class SQLiteEventStore( modules.reversed().forEach { it.deleteAll(db) } } + fun vacuum() { + // 1. ANALYZE: Collects statistics about tables and indices + // to help the query planner optimize queries. + writableDatabase.execSQL("VACUUM") + } + + fun analyse() { + // 2. VACUUM: Rebuilds the database file, reclaiming unused space + // and reducing fragmentation. + writableDatabase.execSQL("ANALYZE") + } + private fun innerInsertEvent( event: Event, db: SQLiteDatabase,