nextcloud / nextcloud/server

Perf: Optimize share providers by fetching the shares in the manager

Open
#58,086 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

🌍 scaling performance 🚀
Dominant language
PHP
Stars
36.9k
Forks
5.2k
Avg merge
2d 3h
Merged PRs (30d)
713

Description

Currently when fetching shares, we first fetch the shares from each provider and then merge the results in the manager. This is inefficient and creates for each share provider (default, federated share, mail, deck, circle and talk) a very similar request where we do a SELECT query where the only difference is a AND share_type = ?.

Instead we could have a createShareFromRow(array $data): IShare in the IShareProvier and let the manager fetch all shares and then call the createShareFromRow corresponding to the provider. This would be much quicker and would allow use to get rid of some duplication.

This comes from #58057 where we are doing an absurd number of SQL request when deleting a group share (around 6 queries per user who had access to the share) and that could be only one. And there is more codepath doing similar queries.

This requires an change in the OCP API. The impact should be not that big as only deck, circle and talk implement this API and they are released at the same time as server.

@AndyScherzinger @nickvergessen @artonge

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the share manager and IShareProvider implementations for the default, federated share, mail, deck, circle, and talk providers. Review the related work in #58057, then verify that fetching shares uses a consolidated query, provider row creation remains compatible with the OCP API, and the excessive per-provider queries are eliminated.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
api, backend
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.