Okay there are multiple local:: entries. Seems like you moved the Nextcloud install dir and data (at least attempted) multiple times?
local::/var/www/nextcloud/data/
local::/home/USER2/Video/
local::/var/www/dokuiki/data/media/USER2/
local::/var/www/dokuiki/data/media/
local::/var/nextcloud/data/
local::/var/www/dokuwiki/data/media/
To be true I am not sure if those include “local” external storages, so when you add a local directory via external storages app.
Also I am not sure how well entries are removed when you remove external storages from within Nextcloud UI, e.g. the two obsolete Dropbox entries.
So before you touch anything, and if downtime is okay, put your Nextcloud into maintenance mode, and do a database dump:
sudo -u www-data php /var/www/nextcloud/occ maintenance:mode --on
sudo mysqldump nextcloud > nextcloud_bak.sql
Then remove the entries that do not match any currently added data dir or external storage:
mysql -e ‘delete from nextcloud.oc_storages where numeric_id = 1’
e.g. to delete the first entry, if this is the old data dir.
You can do the same for the Dropbox entries and others that are definitely not added to Nextcloud anymore or e.g. if the linked directory does not exist anyway.
Use the numeric_id field as this is definitely unique and easiest.
Then disable maintenance mode and check if all users can access their data and external storages as before.
If so then perhaps a cleanup will reduce the file amount in the database but not 100% sure.
But what I am pretty sure about is that all external storage files are added to the database as well (indexed), so perhaps the 1M files matches if you count all files from all external storages as well? And also directories are indexed btw.