[Bug]: Files "Recent" view takes 13–21 s: `mtime OR upload_time` across two tables prevents index use
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 30/100
Piste de recherche
Start from the Recent query in the report: its mtime OR upload_time condition spans oc_filecache and oc_filecache_extended, which stops MariaDB using fs_mtime or fce_utime_idx. Run EXPLAIN on the query and on the UNION-of-candidate-IDs variant described in the issue, then compare. Done when the Recent query uses the indexes, returns the same rows, and finishes well under a second on a large filecache.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
⚠️ This issue respects the following points: ⚠️
- This is not a troubleshooting question, general support matter, or webserver/proxy problem, but likely a bug (if unsure, ask the Community Help Forum).
- This issue is not already reported on Github OR solved at the Community Help Forum (I've searched!).
- I'm using a maintained major version of Nextcloud Server and tested against the latest patch level. (Supported major versions and current patch levels).
- I agree to follow Nextcloud's Code of Conduct.
- I've tried my best to provide clear reproduction steps that someone unfamiliar with this bug could use to reproduce it.
Bug description
Since upload_time was added to recent files (#58327), the query behind the Files "Recent" view combines file.mtime > X OR fe.upload_time > X. The two columns are in different tables (oc_filecache, oc_filecache_extended), so MariaDB cannot use fs_mtime or fce_utime_idx. It falls back to a range scan over all filecache rows of the user's storages.
On this instance, 142 rows match on mtime and 0 on upload_time, but every call examines ~770,000 rows and takes 13–21 s.
Query from the slow log (shortened select list):
SELECT `file`.`fileid`, ... FROM `oc_filecache` `file`
LEFT JOIN `oc_filecache_extended` `fe` ON `file`.`fileid` = `fe`.`fileid`
LEFT JOIN `oc_vcategory_to_object` `tagmap` ON `file`.`fileid` = `tagmap`.`objid`
LEFT JOIN `oc_files_metadata` `meta` ON `file`.`fileid` = `meta`.`file_id`
LEFT JOIN `oc_vcategory` `tag` ON (`tagmap`.`categoryid` = `tag`.`id`) AND (`tag`.`type` = 'files') AND (`tag`.`uid` = '<user>')
WHERE ((`mimetype` <> '2') OR (`size` = 0))
AND ((`mtime` > 1794051606) OR (`upload_time` > 1794051606))
AND (((`storage` = 3) AND ((`path` = 'files') OR (`path` LIKE 'files/%'))) OR (`storage` IN (12, 22)))
ORDER BY GREATEST(`file`.`mtime`, COALESCE(fe.upload_time, 0)) desc LIMIT 100;
# Query_time: 20.915799 Rows_sent: 69 Rows_examined: 769951
# explain: 1 SIMPLE file range fs_storage_mimepart ... rows 851837 r_rows 767816 ... Using index condition; Using where; Using temporary; Using filesort
Selecting the candidate IDs first through both indexes returns the same rows in 0.19 s:
SELECT ... FROM (
SELECT fileid FROM oc_filecache WHERE mtime > 1794051606
UNION
SELECT fileid FROM oc_filecache_extended WHERE upload_time > 1794051606
) u
JOIN oc_filecache file ON file.fileid = u.fileid
LEFT JOIN oc_filecache_extended fe ON ...
WHERE <same storage/mimetype conditions>
ORDER BY ... LIMIT 100;
A WHERE file.fileid IN (... UNION ...) variant does not help: MariaDB turns it into a dependent subquery and scans again (30 s).
Steps to reproduce
- Have a user with large storages in the filecache (here: home + two local external storages, ~770k rows).
- Open Files → Recent.
Expected behavior
The query uses the mtime / upload_time indexes and returns in well under a second.
Actual behavior
Full range scan over all filecache rows of the user's storages, 13–21 s per call.
Nextcloud Server version
35
Operating system
Debian/Ubuntu
PHP engine version
PHP 8.4
Web server
Apache (supported)
Database engine version
MariaDB
Is this bug present after an update or on a fresh install?
None
Are you using the Nextcloud Server Encryption module?
Encryption is Disabled
What user-backends are you using?
- Default user-backend (database)
- LDAP/ Active Directory
- SSO - SAML
- Other
Configuration report
No response
List of activated Apps
No response
Nextcloud Signing status
No errors have been found.
Nextcloud Logs
No log entries; the query shows up only in the MariaDB slow query log (quoted above).
Additional info
Nextcloud 35.0.3, MariaDB 11.8.6, PHP 8.4.28, Debian 13 (aarch64). Validated and reproduced on a live Nextcloud instance; timings above are from that instance.
Assisted by ClaudeCode:claude-opus-5-5
- Langage dominant
- PHP
- Étoiles
- 37.6k
- Forks
- 5.4k
- Merge moyen
- 1 j 13 h
- PR mergées (30 j)
- 623
Préparer son environnement
Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de nextcloud/server
-
[Bug]: Axios Update NeededOuverte0. Needs triage 35-feedback bug
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
34-feedback
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
Les mainteneurs répondent en général sous 1 jour
-
[Bug]: GET /js/../<anything> returns 500 (NotPermittedException from JsController::getJs) instead of 404Peut-être pris @lazerg l’a pris il y a 7 jours. Ouverte35-feedback
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
[Bug]: Dashboard widgets registered via OCA.Dashboard.register() sometimes never mount (spinner forever) – Vue 3 non-deep `callbacks` watcher racePeut-être pris @lazerg l’a pris il y a 7 jours. Ouverte35-feedback
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de nextcloud/server
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
sonata-project/SonataAdminBundle#8426 ·
Les mainteneurs répondent en général sous 1 jour
-
good first issue help wanted
Difficulté 2/5 1-3 heures Accessibilité débutants 90/100
erkamyaman/rust-anything#942 ·
Les mainteneurs répondent en général sous 1 jour
-
CPU core labels missing for Low-Power E-cores on hybrid Intel CPUs (Arrow Lake-H) — get_intel_core_types() ignores /sys/devices/cpu_lowpowerPeut-être pris @dgongut l’a pris aujourd’hui. Ouverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 90/100
Les mainteneurs répondent en général sous 1 jour