If you have a lot of file operations, files can be locked in the database (File is locked - how to unlock), normally this can’t happen to new files that aren’t indexed yet. If you have many users, many parallel uploads or in general many file operations, you should consider using redis.
The main storage is considered to be exclusive to Nextcloud. So every time running the file-scan is not the preferred method, in this case you should take a look at the external storage function which can just be some exchange-folder on your file system. Nextcloud expects changes by external processes in contrast to the main storage. It is automatically scanned upon access.