I followed number of post here and on github, unfortunately I have no references by hand. There is a known bug/misconception in nextcloud which turns into issue
- storages, most often related to external storage used by multiple users is indexed multiple times
- storages removed from NC config remain in DB (check oc_storages DB table)
- records in oc_filecache table remain there (at least until corresponding storage is removed/or forever)
there was an issue on github discussing this more in depth and it looks there is an improvement now filecache records removed by occ files:scan --all/files:cleanup
at least for me running NC 19.0.8 following procedure helped:
- enable external_files app (was removed earlier due to performance issues)
- remove all configured storages
- some external storages are still listed in oc_storages table
- review this records
select * from oc_storages where id like 'smb:%'
- review this records
delete from oc_storages where id like 'smb:%'
- run occ files:cleanup
as a result it removed 160k stale records from file cache.
- running ALTER TABLE oc_filecache FORCE;
returned free space as described here
hopefully this helps!