Skip to content
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

add better index for finding unindexed paths #29118

Merged
merged 1 commit into from
Oct 8, 2021
Merged

Conversation

icewind1991
Copy link
Member

for the following query SELECT "path" FROM "oc_filecache" WHERE ("storage" = $storage) AND ("size" < 0) ORDER BY "fileid" DESC LIMIT 1; which is used by the background scanner.

currently the database will in some cases decide to prioritize the sort by fileid over the filter when picking what index to use, resulting in a much slower query.

by creating an index that allows first sorting by fileid and also filter by storage and size this case will be greatly sped up

Signed-off-by: Robin Appelman robin@icewind.nl

for the following query 'SELECT "path" FROM "oc_filecache" WHERE ("storage" = $storage) AND ("size" < 0) ORDER BY "fileid" DESC LIMIT 1;'

currently the database will in some cases decide to priorize the sort by fileid over the filter when picking what index to use, resulting in a much slower query.

by creating an index that allows first sorting by fileid and also filter by storage and size this case will be greatly sped up

Signed-off-by: Robin Appelman <robin@icewind.nl>
@icewind1991 icewind1991 added the 3. to review Waiting for reviews label Oct 7, 2021
@icewind1991 icewind1991 added this to the Nextcloud 23 milestone Oct 7, 2021
Copy link
Member

@PVince81 PVince81 left a comment

Choose a reason for hiding this comment

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

👍 makes sense

so this is for the BackgroundScanner

@skjnldsv skjnldsv added 4. to release Ready to be released and/or waiting for tests to finish and removed 3. to review Waiting for reviews labels Oct 8, 2021
@PVince81 PVince81 merged commit 1ea5983 into master Oct 8, 2021
@PVince81 PVince81 deleted the incomplete-index branch October 8, 2021 10:07
@PVince81
Copy link
Member

PVince81 commented Oct 8, 2021

@icewind1991 backports? wouldn't be too good for patch releases if we don't want DB updates

@PVince81
Copy link
Member

/backport to stable22

@PVince81
Copy link
Member

/backport to stable21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4. to release Ready to be released and/or waiting for tests to finish performance 🚀
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants