Fix the Nextcloud “Database Missing Some Indexes” Warning

You open Nextcloud’s Administration Overview and see: “The database is missing some indexes.” The warning may appear after an upgrade because Nextcloud can add new indexes to existing tables over time, and it does not always create them automatically on a large database. Missing indexes can make some database queries slower. The supported repair is the built-in occ db:add-missing-indices command.

Before changing the schema, confirm you are running the command for the correct Nextcloud installation, make a database backup, and use the web server’s operating-system user. On versions whose command supports it, preview the proposed SQL with --dry-run. Then run the repair and check the Administration Overview again.

What the warning means

A database index is a structure that helps the database find rows without scanning an entire table. Nextcloud and its apps define indexes for the tables and fields they use. When a newer Nextcloud release or app version introduces an index that an existing installation does not yet have, the admin page can report the mismatch. It is a schema maintenance warning; by itself, it does not mean that the database is corrupt or that user files are missing.

Nextcloud’s administration manual says indexes may be added over time, including to improve performance, and directs administrators to run occ db:add-missing-indices. Adding an index can take time, especially on a large table, and database load or locking behavior can vary by database engine and workload. Plan the change during a quieter period if your instance is busy.

Before you run the repair

  • Confirm the installation path and version. Run commands from the directory containing the intended installation’s occ script, or provide its full path.
  • Back up the database. Use your normal backup procedure for MariaDB/MySQL, PostgreSQL, or SQLite. Verify that the backup completed and that you know how to restore it.
  • Find the HTTP user. Use the account that runs the web server for Nextcloud. Common examples are www-data on Debian or Ubuntu, apache on Fedora or CentOS, http on Arch, and wwwrun on openSUSE. Your deployment may differ.
  • Check for command options. Nextcloud 35’s stable administration manual documents --dry-run. If your installed version does not recognize it, consult that version’s occ db:add-missing-indices --help output and skip the preview rather than assuming the option exists.

The official backup guide lists the database, configuration, data directory, and other installation components that should be retained for a full backup. For this schema operation, at minimum make a tested database backup using the procedure appropriate for your database.

Step 1: Open a shell in the Nextcloud installation

For a traditional Linux installation, connect to the server over SSH and change to the Nextcloud directory. A common Ubuntu path is /var/www/nextcloud, but use the path on your server.

cd /var/www/nextcloud
sudo -E -u www-data php occ status

Confirm that the status output identifies the expected installed instance. If you use a different PHP binary for the web server than the shell’s default php, use the same compatible PHP version for occ. Running occ as the HTTP user helps preserve expected file ownership and permissions.

Step 2: Preview the index changes

If supported by your installed release, run the dry run first:

sudo -E -u www-data php occ db:add-missing-indices --dry-run

The dry run previews the SQL statements without applying them. Read the output and confirm it concerns the missing indexes you intend to repair. If the output identifies a table or index you do not recognize, record its exact name and check whether the relevant app is installed and current. Do not paste previewed SQL into the database console as a shortcut.

Step 3: Add the missing indexes

When the preview is expected and the backup is ready, run the documented repair command:

sudo -E -u www-data php occ db:add-missing-indices

The command checks database tables and creates indexes that are defined in the schema but missing from the current installation. Let it finish. On a large database, this can take a while. Avoid interrupting it while it is changing the schema. Nextcloud’s documentation says this command can be run while the instance remains online; maintenance mode is not listed as a prerequisite for this specific repair. Follow your own change-control process if it requires a maintenance window.

Docker and other installation types

In a containerized deployment, run occ inside the Nextcloud application container, not in the database container. Container and service names vary, so inspect your deployment and substitute the correct name. For a Docker container named nextcloud, the pattern is:

docker exec --user www-data nextcloud php occ db:add-missing-indices

For Docker Compose, the corresponding pattern is docker compose exec -u www-data <nextcloud-service> php occ db:add-missing-indices. Some packaged deployments use a dedicated command or a different container user; use the instructions for that exact package. Do not copy a container name from another person’s setup without verifying it.

If the command fails or the warning remains

  • Permission denied: Verify the HTTP user and the installation path. Do not solve this by running the command as root unless your deployment’s documentation specifically requires a privileged wrapper; the PHP process should generally run as the web server user.
  • Database connection or PHP error: Check the Nextcloud log, database service health, configured PHP version, and the command output. Resolve the underlying connection or runtime issue before rerunning the schema command.
  • Duplicate-key or unique-index error: Stop and keep the full error text. It can indicate conflicting rows that prevent a unique index from being created. Identify the affected app and table, confirm the app and Nextcloud versions, and consult the app’s maintainer or an administrator familiar with that database. Do not delete rows or drop indexes without a data-specific diagnosis and backup.
  • “Command not found” or unsupported option: Confirm that you are in the right Nextcloud installation and check php occ list or php occ help db:add-missing-indices as the HTTP user. Older releases may not expose every newer option.
  • The warning still appears: Refresh Administration Overview after the command exits successfully. Read the warning’s exact index and table names. There may be more than one missing index, a newly introduced index from an app update, a failed database operation, or a schema mismatch that this command did not resolve.

Do not confuse missing indexes with missing columns or primary keys. Nextcloud documents separate commands for those schema changes, such as db:add-missing-columns and db:add-missing-primary-keys. Run a different repair only when the admin warning or the version-specific documentation calls for it.

Verify the result

  1. Wait until db:add-missing-indices exits and reports completion, such as Done.
  2. Reload Administration Overview and confirm that the specific missing-index warning has disappeared.
  3. If it remains, compare its exact table and index names with the command output rather than rerunning blindly.
  4. Check the Nextcloud log and database health for new errors, then confirm that normal file access and the apps that use the affected tables still work.
  5. Keep the backup until the instance has operated normally and your retention policy allows its removal.

For current command syntax, see the Nextcloud database and index command reference. For user and PHP requirements, see Using the occ command and the Nextcloud backup guide. These stable pages identify the current manual as Nextcloud Server 35 when checked on October 6, 2026; paths, options, and packaging instructions can differ in other releases or deployment types.

Leave a Comment

7 Best WSUS Tools for Update Management and Troubleshooting

7 Best WSUS Tools for Update Management and Troubleshooting

Compare seven tools that support or complement WSUS, from Microsoft’s native console and diagnostics to third-party patch publishing and remote deployment.

Best Windows System Monitoring Tools: 6 Picks for Server Visibility

Best Windows System Monitoring Tools: 6 Picks for Server Visibility

Compare six Windows system monitoring tools for server health, application visibility, and alerting, with current notes on deployment and licensing.

7 Wake-on-LAN Tools: What’s Still Available From the 2021 List

7 Wake-on-LAN Tools: What’s Still Available From the 2021 List

Compare seven Wake-on-LAN tools by features and availability, including free utilities, network-admin suites, and 2021 picks that have since been retired.

9 Best Ping Tools for Testing Latency and Scanning a Network

9 Best Ping Tools for Testing Latency and Scanning a Network

Compare nine ping tools for quick reachability checks, subnet discovery, TCP tests, and latency monitoring, with guidance on which one fits your network task.

Best TFTP Servers for Windows, Linux, and macOS

Best TFTP Servers for Windows, Linux, and macOS

Compare the best TFTP servers for Windows, Linux, and macOS, including SolarWinds, Tftpd64, tftpd-hpa, atftpd, haneWIN, and dnsmasq.

5 Best Microsoft Access Alternatives for Desktop and Web Databases

5 Best Microsoft Access Alternatives for Desktop and Web Databases

Compare five Microsoft Access alternatives for desktop, SQLite, no-code, and browser-based database work, with strengths, limits, and best-fit use cases.

Open-Source vs. Closed-Source Monitoring Tools Compared

Open-Source vs. Closed-Source Monitoring Tools Compared

Compare open-source and closed-source monitoring tools by cost, support, customization, security, and current options including Zabbix, Nagios, PRTG, and more.

Ingress vs. Egress: What’s the Difference in Networking?

Ingress vs. Egress: What’s the Difference in Networking?

Understand how ingress and egress describe incoming and outgoing traffic, why direction depends on the network boundary, and how to monitor bandwidth and spot risky data transfers.

6 Best Free Syslog Servers to Try for Centralized Logging

6 Best Free Syslog Servers to Try for Centralized Logging

Compare six free syslog servers and collectors for Windows and Linux, including GUI tools, open-source options, search, alerting, and secure transport.

What Is IIS? Microsoft’s Windows Web Server and Alternatives

What Is IIS? Microsoft’s Windows Web Server and Alternatives

See what Microsoft IIS does, how its request pipeline and application pools work, and when Apache, NGINX, or Caddy may fit your web server needs better.