SQL commands for missing indices

Support intro

I search for sql-commands for creating missing indices

Nextcloud version 27.0.2
Operating system and version Webhosting environment

try searching the forum and the docs… there miraids of topics talking about “occ db:add-missing-indices"

1 Like

It’s fully documented in the “How to upgrade” section of the Admin Manual. Here’s the direct link to the spot you’re looking for.

P.S. The manual is fully searchable by keyword.

1 Like

Many Thanks for your answers, but I can’t run occ in my environment so I serach for the SQL-Commands alter table…
or can anybody tell mye where can I find the php-script add-missing-indices?
Best regards
Peter

Voila (for your version 27.0.2):

There is even an option “–dry-run” to provide the SQL queries instead of running them.

But unfortunately that does not work on mysql instances (I filed a bugreport for that already) but on a postgre SQL instance I got the query. It looks like:

Adding additional textstep_session index to the oc_text_steps table, this can take some time…

CREATE INDEX textstep_session ON oc_text_steps (session_id);

So looking in the code wil show, what indices have to be added and my example should help you to generate the SQL queries for them.

Hope that helps,
much luck!

1 Like

Can you tell us more details about this? - If you have access to SQL command line, you also should have access to occ, if you use the correct syntax and path.

Tell me which Indices your nextcloud is missing exactly and I will try to get it in the right form for you:

here one more example:

to add the mounts_class_index index on the mount_provider_class column in the oc_mounts table:

CREATE INDEX mounts_class_index ON oc_mounts (mount_provider_class);

and to add the mounts_user_root_path_index index on the user_id, root_id and mount_point column in the oc_mounts table:

CREATE INDEX mounts_user_root_path_index ON oc_mounts (user_id, root_id, mount_point);

ernolf

Even though you didn’t ask me: Some providers do not allow ssh access while the database can be managed with other interfaces.

1 Like