Repository navigation
⚡ Bolt: Add Room database indices for sleep session queries - #5
Conversation
- Add index on startTimeMillis for fast ORDER BY queries - Add index on syncedToHealthConnect for fast unsynced session filtering - Add MIGRATION_1_2 to preserve user data when upgrading schema Co-authored-by: felixbrucker <5189997+felixbrucker@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Coverage Report
|
| ).build() | ||
| ) | ||
| .addMigrations(MIGRATION_1_2) | ||
| .fallbackToDestructiveMigration(dropAllTables = true) |
There was a problem hiding this comment.
Never fallback to destructive migrations
There was a problem hiding this comment.
Done. Removed fallbackToDestructiveMigration entirely.
| "sleep_tracker.db" | ||
| ).build() | ||
| ) | ||
| .addMigrations(MIGRATION_1_2) |
There was a problem hiding this comment.
Don't use manual migrations unless necessary, use automigrations instead
There was a problem hiding this comment.
Done. Replaced manual migration with Room's @AutoMigration(from = 1, to = 2).
- Replace manual Migration(1, 2) with Room @AutoMigration(from = 1, to = 2) - Remove fallbackToDestructiveMigration Co-authored-by: felixbrucker <5189997+felixbrucker@users.noreply.github.com>
💡 What
Added SQLite indices on
startTimeMillisandsyncedToHealthConnectcolumns inSleepSessionEntity, updated Room database version to 2, exported the new database schema, and addedMIGRATION_1_2to migrate existing databases without data loss.🎯 Why
The
sleep_sessionsdatabase table is queried frequently on app launch and background syncs:getAllSessions()orders all records bystartTimeMillis DESC.getUnsyncedSessions()filters for records wheresyncedToHealthConnect = 0.Without indices, SQLite must perform full table scans (O(N)) for these queries as the history grows over time.
📊 Impact
🔬 Measurement
Verified via Room schema verification and full unit test execution (
./gradlew test --no-configuration-cache).PR created automatically by Jules for task 7391568008993684424 started by @felixbrucker