Skip to content

perf: Add index on TransferDB.createdAt to speed up queries - #300

Open
LouisCAD wants to merge 2 commits into
mainfrom
add-db-index
Open

perf: Add index on TransferDB.createdAt to speed up queries#300
LouisCAD wants to merge 2 commits into
mainfrom
add-db-index

Conversation

@LouisCAD

@LouisCAD LouisCAD commented May 13, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings May 13, 2026 13:35
@LouisCAD
LouisCAD enabled auto-merge May 13, 2026 13:38
@LouisCAD
LouisCAD disabled auto-merge May 13, 2026 13:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to improve Room query performance by adding an index on TransferDB.createdAt, and updates the Room database schema accordingly.

Changes:

  • Add a Room index on TransferDB.createdAt.
  • Bump AppDatabase version from 1 → 2 and declare an auto-migration (1 → 2).
  • Add the exported Room schema for version 2 (2.json).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
STDatabase/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/database/models/transfers/v2/TransferDB.kt Adds a Room index declaration for createdAt on the TransferDB entity.
STDatabase/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/database/DatabaseProvider.kt Bumps Room DB version to 2 and declares an auto-migration from version 1.
STDatabase/schemas/com.infomaniak.multiplatform_swisstransfer.database.AppDatabase/2.json Adds the generated Room schema snapshot for DB version 2 (includes the new index).
Comments suppressed due to low confidence (1)

STDatabase/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/database/models/transfers/v2/TransferDB.kt:29

  • The new index is only on createdAt, but the most frequent queries against TransferDB also filter by userOwnerId and/or transferStatus while ordering by createdAt (see TransferDao.transfersFlow / validTransfersFlow). A single-column createdAt index may provide limited benefit; consider a composite index that matches the filter + sort pattern (e.g., (userOwnerId, createdAt) or (userOwnerId, transferStatus, createdAt)) to better support these queries.
@Entity(indices = [Index("createdAt")])

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sonarqubecloud

sonarqubecloud Bot commented Jun 9, 2026

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comment thread STDatabase/build.gradle.kts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants