Querying oc_preferences by value is slow on large tables
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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