Filescan in large environments

Nextcloud version (eg, 29.0.5): 29.0.3
Operating system and version (eg, Ubuntu 29.04): 22.04.4 LTS
Apache or nginx version (eg, Apache 2.4.25):
PHP version (eg, 8.3): 8.1.28

The issue you are facing: Filescan takes days to complete.
I have the Nextcloud as an access option from the web for an SMB file structure.
I have connected various external SMB shares.
One of them is very large (more than 1 800 000 files and more than 3TB).
I think the filescan bites its teeth out there and the scans run for more than 12 hours…
As I understand it, the scan runs for each user individually…
This means that the previews and the database are also filled individually for each user and my Nextcloud is full without any data being actively stored there…

The big folder is the same for all users.
I need a solution to the problem.

The output of your Nextcloud log in Admin > Logging:

Background job OCA\Files\BackgroundJob\ScanFiles (id: 3, arguments: null) ran for 44430 seconds

So every user has mounted in Nextcloud his/her own SMB storage?

For my external storage, I can say it should scan on access or never scan external storage. So in therory it should happen in the background and probably just for folders you are scanning through. (in my case it was SFTP/SCP).
In such a case, storage is scanned for each user individually.

If it is the same storage, you could mount it for the admin user, and then share this to the other users. Then you should be able to scan it on usage as well, but users will benefit from each other’s updates.

So you don’t update on access, and you do it manually through a cron job?

In such a case, I’d try to find out where the bottle neck is. I think especially towards the databse, if you can’t optimize cache sizes… or if it is the network (e.g. compare to filescan performance on local drive).