nextcloud / nextcloud/server

Querying oc_preferences by value is slow on large tables

Open
#42,505 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

1. to develop performance 🚀 technical debt
Dominant language
PHP
Stars
36.9k
Forks
5.2k
Avg merge
2d 3h
Merged PRs (30d)
713

Description

There are code paths that query all users that have a give value in oc_preferences which is slow due to no index being added on the value field. Some instances solved this with adding a partial index but we should rather:

https://github.com/nextcloud/server/blob/3cd1d74a815531c9b7ae25ebbf8e7c45fa566e74/lib/private/AllConfig.php#L523
https://github.com/nextcloud/server/blob/3cd1d74a815531c9b7ae25ebbf8e7c45fa566e74/lib/private/AllConfig.php#L489

  • Add a hash column to access by value with an index
  • Also have a lower case hash value stored with an index

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

Read lib/private/AllConfig.php at the referenced lines 489 and 523, then trace the preference lookups described in the issue. Review the database schema or migration path for adding indexed hash and lower-case hash values, and verify that the affected large-table queries use them.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.