-
-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DB: some missing indices #890
Conversation
The Collection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What @rfc2822 said :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, compilation of the tests still shows this message (in the assembleDebug
step):
w: [ksp] /home/runner/work/davx5-ose/davx5-ose/app/src/main/kotlin/at/bitfire/davdroid/db/WebDavDocument.kt:33: parentId column references a foreign key but it is not part of an index. This may trigger full table scans whenever parent table is modified so you are highly advised to create an index that covers this column.
@ArnyminerZ Do you have an idea where this could come from?
56854d9
to
762e1c8
Compare
After a rebase, the message is still there:
|
I've tried everything that came up to my mind, and this is the only thing that works. I don't know if it's a bug, or if it's supposed to be this way, but the warning should be gone. |
Working on the failing tests |
Index("mountId", "parentId", "name", unique = true) | ||
Index("mountId"), | ||
Index("parentId"), | ||
Index("name", unique = true), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would forbid the same file name ("README") to be present in different directories/mounts. We should keep the original index, if possible.
Above two foreign keys with childColumn=mountId
and childColumn=parentId
are defined. ForeignKey
docs say:
It is also recommended to create an index on the child table to avoid full table scans when the parent table is modified. If a suitable index on the child table is missing, Room will print RoomWarnings. MISSING_INDEX_ON_FOREIGN_KEY_CHILD warning.
So we need two indices:
mountId
(will be used to find the children when aWebDavMount
is deleted) – this is already covered by theIndex("mountId", "parentId", "name", unique = true)
index because it's the leftmost column, andparentId
(will be used to find the children when aWebDavDocument
is deleted).
It should be enough to just add a normal index about parentId
.
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora Gras <arnyminerz@proton.me>
173c02b
to
52f98ad
Compare
Looks good, works and all warnings gone :) |
Purpose
Add missing indices to database
Short description
Collection#ownerId
.WebDavDocument#parentId
Checklist