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

fix: Split query to fetch board ids to avoid slow query join #4906

Merged
merged 1 commit into from
Jul 21, 2023

Conversation

juliushaertl
Copy link
Member

@juliushaertl juliushaertl commented Jul 13, 2023

Summary

Some over optimization for query count caused this slow query, which does seem to do a full table scan on the boards table (left part of the join):

SELECT DISTINCT b.id FROM oc_deck_boards b 
	LEFT JOIN oc_deck_board_acl acl ON b.id = acl.board_id 
	WHERE (owner = 'user1')
	OR ((acl.participant = 'user1') AND (acl.type = 0)) 
	OR ((acl.participant IN ('group', 'group1')) AND (acl.type = 1));

Doing two queries instead still seems more reasonable as I also couldn't think of a more performant option.

@cypress
Copy link

cypress bot commented Jul 13, 2023

Passing run #1147 ↗︎

0 15 0 0 Flakiness 0

Details:

Merge fe319c8 into 554efab...
Project: Deck Commit: 8b5edfcc5b ℹ️
Status: Passed Duration: 02:33 💡
Started: Jul 21, 2023 1:16 PM Ended: Jul 21, 2023 1:19 PM

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings.

Copy link
Member

@mejo- mejo- left a comment

Choose a reason for hiding this comment

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

To be honest I don't understand the change. If I read the code changes correctly, one SQL query is split into two now, but the second new query looks exactly like the old one to me.

The first new query doesn't have the "Shared to [user/groups/circles]" condition, so it returns only the owned boards. But the second still has both conditions: owned boards and shared boards.

Maybe you meant to remove the "Owned by the user" condition from the second query? 🤔

It's well possible that I just don't understand the code. DB queries are certainly not my field of expertise 😬

@juliushaertl juliushaertl force-pushed the bugfix/noid/board-split-query branch from 07658c3 to c3ebee3 Compare July 21, 2023 11:16
Copy link
Member

@mejo- mejo- left a comment

Choose a reason for hiding this comment

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

Code changes look good to me now 😊

@juliushaertl

This comment was marked as resolved.

Signed-off-by: Julius Härtl <jus@bitgrid.net>
@juliushaertl juliushaertl force-pushed the bugfix/noid/board-split-query branch from c3ebee3 to fe319c8 Compare July 21, 2023 13:11
@juliushaertl juliushaertl merged commit a847158 into main Jul 21, 2023
24 checks passed
@juliushaertl juliushaertl deleted the bugfix/noid/board-split-query branch July 21, 2023 16:08
@juliushaertl
Copy link
Member Author

/backport to stable27

@juliushaertl
Copy link
Member Author

/backport to stable26

@backportbot-nextcloud
Copy link

The backport to stable27 failed. Please do this backport manually.

# Switch to the target branch and update it
git checkout stable27
git pull origin stable27

# Create the new backport branch
git checkout -b fix/foo-stable27

# Cherry pick the change from the commit sha1 of the change against the default branch
# This might cause conflicts. Resolve them.
git cherry-pick abc123

# Push the cherry pick commit to the remote repository and open a pull request
git push origin fix/foo-stable27

More info at https://docs.nextcloud.com/server/latest/developer_manual/getting_started/development_process.html#manual-backport

@backportbot-nextcloud
Copy link

The backport to stable26 failed. Please do this backport manually.

# Switch to the target branch and update it
git checkout stable26
git pull origin stable26

# Create the new backport branch
git checkout -b fix/foo-stable26

# Cherry pick the change from the commit sha1 of the change against the default branch
# This might cause conflicts. Resolve them.
git cherry-pick abc123

# Push the cherry pick commit to the remote repository and open a pull request
git push origin fix/foo-stable26

More info at https://docs.nextcloud.com/server/latest/developer_manual/getting_started/development_process.html#manual-backport

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

2 participants