Skip to content

perf(sharing): Avoid loading all shares from all users when unsharing#58057

Open
CarlSchwan wants to merge 1 commit intomasterfrom
carl/perf-delete-share
Open

perf(sharing): Avoid loading all shares from all users when unsharing#58057
CarlSchwan wants to merge 1 commit intomasterfrom
carl/perf-delete-share

Conversation

@CarlSchwan
Copy link
Member

Summary

First check which users have a shares and for which providers and then only load these shares.

Avoid doing at most 5 SQL queries for each users a share was shared with if there are no shares.

Checklist

@CarlSchwan CarlSchwan added this to the Nextcloud 34 milestone Feb 4, 2026
@CarlSchwan CarlSchwan self-assigned this Feb 4, 2026
@CarlSchwan CarlSchwan requested a review from a team as a code owner February 4, 2026 14:23
@CarlSchwan CarlSchwan requested review from ArtificialOwl, icewind1991, leftybournes and salmart-dev and removed request for a team February 4, 2026 14:23
// Figure out which users has some shares with which providers
$qb = $this->connection->getQueryBuilder();
$qb->select('uid_initiator', 'share_type')
->from('share')
Copy link
Member

Choose a reason for hiding this comment

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

But not all providers save their data in this table, no?

Copy link
Member Author

@CarlSchwan CarlSchwan Feb 4, 2026

Choose a reason for hiding this comment

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

At least talk, deck, circles and all the one in server do. I don't think there are more of them as the list is hardcoded in server

Copy link
Member

Choose a reason for hiding this comment

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

I was thinking of federated shares, because it uses two tables, one for incoming and one for outgoing. I'm not entirely sure if this would be covered here.

Copy link
Member Author

Choose a reason for hiding this comment

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

federated shares getSharesBy is also just checking the share table only. Ultimately, I think we should make the manager fetch the share data and then let the providers create the IShare with the createShare method.

This would make sharing quite a bit lighter

Copy link
Member

Choose a reason for hiding this comment

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

Yes, but all share providers are slightly different and it's hard to unify all the logic.

@CarlSchwan CarlSchwan force-pushed the carl/perf-delete-share branch from 834817d to d600563 Compare February 4, 2026 15:27
First check which users have a shares and for which providers and then
only load these shares.

Avoid doing at most 5 SQL queries for each users a share was shared with if
there are no shares.

Signed-off-by: Carl Schwan <carlschwan@kde.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants