# DB missing index on NC 14

**URL:** <https://help.nextcloud.com/t/db-missing-index-on-nc-14/37048>\
**Category:** ℹ️ Support\
**Tags:** update\_problems, nc14, synology\
**Created:** [September 17, 2018, 8:50pm UTC](https://help.nextcloud.com/t/db-missing-index-on-nc-14/37048 "2018-09-17T20:50:37Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Delor3an91](https://help.nextcloud.com/user_avatar/help.nextcloud.com/delor3an91/32/11375_2.png) [@Delor3an91](https://help.nextcloud.com/u/Delor3an91)\
**Post date:** [September 17, 2018, 8:50pm UTC](https://help.nextcloud.com/t/db-missing-index-on-nc-14/37048/1 "2018-09-17T20:50:38Z")

</div>

I’ve updated to NC14 and I need to run

occ db:add-missing-index

but I am on Synology NAS and don’t have the ability to run occ command

How can I do ?

How can I add those indexes with SQL request ?

```
Index "share_with_index" missing on table "share"
Index "parent_index" missing on table "share"
Index "fs_mtime" missing on table "filecache"

```

Thanks

Regards,

Delor3an

---

<div class="post-metadata">

**Author:** ![timm2k](https://help.nextcloud.com/user_avatar/help.nextcloud.com/timm2k/32/7493_2.png) [@timm2k](https://help.nextcloud.com/u/timm2k)\
**Post date:** [September 18, 2018, 12:53pm UTC](https://help.nextcloud.com/t/db-missing-index-on-nc-14/37048/2 "2018-09-18T12:53:47Z")

</div>

If you have access to your database via cli or phpMyAdmin:

`ALTER TABLE __nextcloud__.oc_share ADD INDEX share_with_index (share_with) USING BTREE;`  
`ALTER TABLE __nextcloud__.oc_share ADD INDEX parent_index (parent) USING BTREE;`

Replace ` __nextcloud__ ` with your database schema name.  
I don’t have an index of fs\_mtime in table fillecache.

---

<div class="post-metadata">

**Author:** ![Delor3an91](https://help.nextcloud.com/user_avatar/help.nextcloud.com/delor3an91/32/11375_2.png) [@Delor3an91](https://help.nextcloud.com/u/Delor3an91)\
**Post date:** [September 18, 2018, 8:19pm UTC](https://help.nextcloud.com/t/db-missing-index-on-nc-14/37048/3 "2018-09-18T20:19:14Z")

</div>

Hi timm2k,

What do you mean by database schema name ?

if my DB name is ‘test’ and table prefix is empty ‘’.

Is that correct ?

`ALTER TABLE test.share ADD INDEX share_with_index (share_with) USING BTREE;`  
`ALTER TABLE test.share ADD INDEX parent_index (parent) USING BTREE;`

Regards,

Delor3an

---

<div class="post-metadata">

**Author:** ![timm2k](https://help.nextcloud.com/user_avatar/help.nextcloud.com/timm2k/32/7493_2.png) [@timm2k](https://help.nextcloud.com/u/timm2k)\
**Post date:** [September 19, 2018, 6:50am UTC](https://help.nextcloud.com/t/db-missing-index-on-nc-14/37048/4 "2018-09-19T06:50:02Z")

</div>

correct 🙂

---

<div class="post-metadata">

**Author:** ![neo76](https://help.nextcloud.com/letter_avatar/neo76/32/5_5575768a8748004e209b776fc1b2916d.png) [@neo76](https://help.nextcloud.com/u/neo76)\
**Post date:** [October 14, 2018, 11:35am UTC](https://help.nextcloud.com/t/db-missing-index-on-nc-14/37048/5 "2018-10-14T11:35:01Z")

</div>

Perfect!  
For fs\_mtime is:

My tables NOT use prefix\_!!

ALTER TABLE oc\_filecache ADD INDEX fs\_mtime (mtime) USING BTREE;

(Not to my belly!  
I have just installed nc 14 in a single installer and checked that I can not …)

---

<div class="post-metadata">

**Author:** ![FinnTheHuman](https://help.nextcloud.com/user_avatar/help.nextcloud.com/finnthehuman/32/8634_2.png) [@FinnTheHuman](https://help.nextcloud.com/u/FinnTheHuman)\
**Post date:** [October 14, 2018, 6:26pm UTC](https://help.nextcloud.com/t/db-missing-index-on-nc-14/37048/6 "2018-10-14T18:26:48Z")

</div>

I’ve just updated my Synology NC 13.0.7 to 14.0.3.  
I got the same security warning to update my DB index and run that command. This is what I did to run it.

- Login to your Synology CLI
- go to the directory of you nextcloud web folder
- run this command there: sudo -u http php70 occ db:add-missing-indices

Note1: If you don’t run the command in the correct folder it will give an error: “Could not open input file: occ”  
Note2: This depends on you Synoligy setup, but DSM uses php 5.6.11 as default from terminal when using php cmd. NC14 require php7.0 (hens the php70 command).  
Note3: If you have a task running for the cron job, you might want to change that to php70 as well.

---

<div class="post-metadata">

**Author:** ![Delor3an91](https://help.nextcloud.com/user_avatar/help.nextcloud.com/delor3an91/32/11375_2.png) [@Delor3an91](https://help.nextcloud.com/u/Delor3an91)\
**Post date:** [October 16, 2018, 1:41am UTC](https://help.nextcloud.com/t/db-missing-index-on-nc-14/37048/7 "2018-10-16T01:41:05Z")

</div>

Hi FinnTheHuman,

This command doesn’t work on DSM 6.2.1-23824

Regards

---

<div class="post-metadata">

**Author:** ![FinnTheHuman](https://help.nextcloud.com/user_avatar/help.nextcloud.com/finnthehuman/32/8634_2.png) [@FinnTheHuman](https://help.nextcloud.com/u/FinnTheHuman)\
**Post date:** [October 16, 2018, 7:00am UTC](https://help.nextcloud.com/t/db-missing-index-on-nc-14/37048/8 "2018-10-16T07:00:30Z")

</div>

I’m running same version as you. What’s not working?  
My setup:

- Synology NAS with DSM 6.2.1-23824.
- PHP 7.0.30 and MariaDB 10.3.7-0051

I made a post about my NC upgrade from 13.07 to 14.0.3 her:

> [@Synology update NC 13.0.7 to NC 14.0.3](https://help.nextcloud.com/t/synology-update-nc-13-0-7-to-nc-14-0-3/39123):
>
> As I had some minor issues during this update I guess I should share the experience. My Setup: Synology NAS with DSM 6.2.1-23824. PHP 7.0.30 & MariaDB 10.3.7-0051 Migrated from OC 10 to NC 12 in April 2018. - post in howto section. And also why data folder is named owncloud. Change the folder names to fit your folders. My NC installation don’t have any additional addons or apps installed My data directory is on a different drive than web Note: DSM terminal uses php 5.6.11 by default. php = 5…

Have a look and see if it can help

---

<div class="post-metadata">

**Author:** ![sascha224](https://help.nextcloud.com/user_avatar/help.nextcloud.com/sascha224/32/11407_2.png) [@sascha224](https://help.nextcloud.com/u/sascha224)\
**Post date:** [October 18, 2018, 2:59pm UTC](https://help.nextcloud.com/t/db-missing-index-on-nc-14/37048/9 "2018-10-18T14:59:05Z")

</div>

I’m also having trouble executing the command you posted.  
The error message from shell:

```
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php70/modules/libsodium.so' - /usr/local/lib/php70/modules/libsodium.so: cannot open shared object file: No such file or directory in Unknown on line 0
An unhandled exception has been thrown:
Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occured in driver: could not find driver in /volume1/web/nextcloud/lib/private/DB/Connection.php:64

```

System is DSM 6.2.1-23824, Nextcloud is configured to run with PHP7.0 since v13.x. Do you have an idea?

---

<div class="post-metadata">

**Author:** ![Delor3an91](https://help.nextcloud.com/user_avatar/help.nextcloud.com/delor3an91/32/11375_2.png) [@Delor3an91](https://help.nextcloud.com/u/Delor3an91)\
**Post date:** [October 18, 2018, 3:13pm UTC](https://help.nextcloud.com/t/db-missing-index-on-nc-14/37048/10 "2018-10-18T15:13:19Z")

</div>

Hi,

@sascha224 I’ve got exactly the same error message !

@FinnTheHuman May you please let us know what did you do to make it works ?

It was OK to execute occ on DSM 6.0/6.1 with php56 but now it’s not working.

Regards

---

<div class="post-metadata">

**Author:** ![FinnTheHuman](https://help.nextcloud.com/user_avatar/help.nextcloud.com/finnthehuman/32/8634_2.png) [@FinnTheHuman](https://help.nextcloud.com/u/FinnTheHuman)\
**Post date:** [October 18, 2018, 8:28pm UTC](https://help.nextcloud.com/t/db-missing-index-on-nc-14/37048/11 "2018-10-18T20:28:03Z")

</div>

> [@sascha224](#):
>
> Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occured in driver: could not find driver in /volume1/web/nextcloud/lib/private/DB/Connection.php

Well, I’m no expert on the matter, but this sounds like a PHP 7.0 configuration issue. And I have to be honest, the PHP configuration of the synology is hard to understand. But I’ll try to point you in some directions.

- On Synology running PHP from CLI uses different php.ini files than PHP ran from web page
- WebStation PHP settings can be set in the WebStation DSM web GUI, and PHP settings for CLI needs to be addressed from CLI.
- It’s important that both php configurations point the **extention\_dir** to the correct directory:  
Mine is set to:  
/volume3/@appstore/PHP7.0/usr/local/lib/php70/modules  
But yours could be on a different volume depending on your volume for @appstore.

To see your PHP configrations

- running: **php70 -ini** from CLI will tell you where and what ini files are loaded when running php70 from CLI.
- The same information for webstation can be obtained by loading a xxx.php file in the browser containing phpinfo() command  
‘\<?php phpinfo(); ?\>’  
Of cause the settings from the configuration files is also available in DSM Web GUI for the WebStation.

I do see some other solutions to solve the php.ini issues. like using the -c command to direct php to a different path for php.ini file. It’s also possible, but I’ve not tried it.

- It’s also important that **mysqli** and **pdo\_mysql** are enabled for the PHP7 configurations. Though I would assume this is ok in your setup.

Hope it helps you a little bit on the way to find solutions.

---

<div class="post-metadata">

**Author:** ![sascha224](https://help.nextcloud.com/user_avatar/help.nextcloud.com/sascha224/32/11407_2.png) [@sascha224](https://help.nextcloud.com/u/sascha224)\
**Post date:** [October 19, 2018, 11:30am UTC](https://help.nextcloud.com/t/db-missing-index-on-nc-14/37048/12 "2018-10-19T11:30:40Z")

</div>

Thanks for your help. I changed the path in php.ini of CLI, but then I got error messages that the module builds don’t match to the PHP build. But with the other way, parameter -c, I were successful. The profiles of DSM-PHP are located here:

`/var/packages/WebStation/etc/php_profile`

The only problem is to find out the correct profile you use for your Nextcloud setup, I would suggest to inspect the file /conf.d/user\_settings.ini, here you can try to identify your needed PHP-profile via activated extensions. Then I had to execute the following command:

```
sudo -u http /usr/local/bin/php70 -c /var/packages/WebStation/etc/php_profile/<yourPHPprofileID>/conf.d/user_settings.ini -f /volume1/web/nextcloud/occ db:add-missing-indices

```

That worked for me and created the missing indices.

---

<div class="post-metadata">

**Author:** ![system](https://help.nextcloud.com/user_avatar/help.nextcloud.com/system/32/29333_2.png) [@system](https://help.nextcloud.com/u/system)\
**Post date:** [September 23, 2024, 5:44pm UTC](https://help.nextcloud.com/t/db-missing-index-on-nc-14/37048/13 "2024-09-23T17:44:27Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [December 9, 2024, 3:18pm UTC](https://help.nextcloud.com/t/db-missing-index-on-nc-14/37048/14 "2024-12-09T15:18:53Z")

</div>


