-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
optimize query pattern used by storage filter #40555
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
icewind1991
force-pushed
the
query-optimize-distribute
branch
from
September 21, 2023 13:18
8cd1341
to
3b637f8
Compare
icewind1991
force-pushed
the
query-optimize-distribute
branch
2 times, most recently
from
September 21, 2023 14:54
e4a4a9f
to
28d41e3
Compare
An example search query with a number of single file and folder shares from 2 users and a few groupfolders From SELECT `file`.`fileid`,
`storage`,
`path`,
`path_hash`,
`file`.`parent`,
`file`.`name`,
`mimetype`,
`mimepart`,
`size`,
`mtime`,
`storage_mtime`,
`encrypted`,
`etag`,
`permissions`,
`checksum`,
`unencrypted_size`
FROM `*PREFIX*filecache` `file`
WHERE (`file`.`name` ILIKE :"%tesa%")
AND (((`storage` = :1) AND
((`path` = :"files") OR (`path` LIKE :"files\/%"))) OR
((`storage` = :2) AND ((`path` = :"__groupfolders\/1") OR
(`path` LIKE :"\\_\\_groupfolders\/1\/%"))) OR
((`storage` = :2) AND ((`path` = :"__groupfolders\/2") OR
(`path` LIKE :"\\_\\_groupfolders\/2\/%"))) OR
((`storage` = :4) AND (`path` = :"files\/cv.md")) OR
((`storage` = :3) AND (`path` = :"files\/boilerplate.md")) OR
((`storage` = :3) AND ((`path` = :"files\/testfolder") OR
(`path` LIKE :"files\/testfolder\/%"))) OR
((`storage` = :3) AND (`path` = :"files\/oc-react.md")) OR
((`storage` = :3) AND (`path` = :"files\/Patcher.md")) OR
((`storage` = :3) AND (`path` = :"files\/storage.md")) OR
((`storage` = :3) AND (`path` = :"files\/welcome.txt")) OR
((`storage` = :3) AND (`path` = :"files\/oc-news-feed.md")) OR
((`storage` = :4) AND (`path` = :"files\/rssrun.md")) OR
((`storage` = :4) AND (`path` = :"files\/Replay.md")) OR
((`storage` = :4) AND (`path` = :"files\/regen.md")) OR
((`storage` = :3) AND ((`path` = :"files\/sharefolder2") OR
(`path` LIKE :"files\/sharefolder2\/%"))) OR
((`storage` = :3) AND ((`path` = :"files\/sharefolder3") OR
(`path` LIKE :"files\/sharefolder3\/%"))))
ORDER BY `mtime` + :0 desc LIMIT 5 to SELECT `file`.`fileid`,
`storage`,
`path`,
`path_hash`,
`file`.`parent`,
`file`.`name`,
`mimetype`,
`mimepart`,
`size`,
`mtime`,
`storage_mtime`,
`encrypted`,
`etag`,
`permissions`,
`checksum`,
`unencrypted_size`
FROM `*PREFIX*filecache` `file`
WHERE (`file`.`name` ILIKE :"%tes%")
AND (((`storage` = :1) AND
((`path` = :"files") OR (`path` LIKE :"files\/%"))) OR
((`storage` = :2) AND
((`path` IN (:["__groupfolders\/1", "__groupfolders\/2"])) OR
(`path` LIKE :"\\_\\_groupfolders\/1\/%") OR
(`path` LIKE :"\\_\\_groupfolders\/2\/%"))) OR ((`storage` = :4) AND
(`path` IN
(:["files\/cv.md",
"files\/rssrun.md",
"files\/Replay.md",
"files\/regen.md"]))) OR
((`storage` = :3) AND ((`path` IN
(:["files\/boilerplate.md", "files\/testfolder",
"files\/oc-react.md", "files\/Patcher.md",
"files\/storage.md", "files\/welcome.txt",
"files\/oc-news-feed.md", "files\/sharefolder2",
"files\/sharefolder3"])) OR
(`path` LIKE :"files\/testfolder\/%") OR
(`path` LIKE :"files\/sharefolder2\/%") OR
(`path` LIKE :"files\/sharefolder3\/%"))))
ORDER BY `mtime` + :0 desc LIMIT 5 |
9 tasks
icewind1991
force-pushed
the
query-optimize-distribute
branch
2 times, most recently
from
September 22, 2023 11:15
63c7d16
to
1e79a5f
Compare
Merged
@icewind1991 Any plans for an updated pull for NC28? Search for files is back to more than 60 seconds on my instance (thus, search is practically unusable). |
icewind1991
force-pushed
the
query-optimize-distribute
branch
from
February 5, 2024 09:17
1e79a5f
to
03234a3
Compare
icewind1991
force-pushed
the
query-optimize-distribute
branch
5 times, most recently
from
February 5, 2024 17:56
aba15a1
to
89ea173
Compare
icewind1991
force-pushed
the
query-optimize-distribute
branch
2 times, most recently
from
February 7, 2024 09:17
14b1ca1
to
18b5963
Compare
Signed-off-by: Robin Appelman <robin@icewind.nl>
…ents Signed-off-by: Robin Appelman <robin@icewind.nl>
Signed-off-by: Robin Appelman <robin@icewind.nl>
Signed-off-by: Robin Appelman <robin@icewind.nl>
Signed-off-by: Robin Appelman <robin@icewind.nl>
artonge
approved these changes
Feb 15, 2024
icewind1991
force-pushed
the
query-optimize-distribute
branch
2 times, most recently
from
February 15, 2024 18:26
5cc8bb5
to
fcafb9e
Compare
ArtificialOwl
approved these changes
Feb 16, 2024
Signed-off-by: Robin Appelman <robin@icewind.nl>
icewind1991
force-pushed
the
query-optimize-distribute
branch
from
February 16, 2024 09:59
fcafb9e
to
3890aa5
Compare
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
To filter searches based on the storages a user has access to search queries often include multiple
(storage = $1 and path like "$2/%")
(for folder shares/groupfolders) and(storage = $1 and path = $2)
(for single file shares) parts.This attempts to optimize those queries by
(storage = $1 and $path like $2) or (storage = $1 and $path like $3)
->storage = $1 and ($path like $2 or $path like $3)
=
on the same field with anin
:(path = $1 or path = $2 or $path = 3)
->path in ($1,$2,$3)
todo:
in
statements