# Help with occ db:add-missing-indices

**URL:** <https://help.nextcloud.com/t/help-with-occ-db-add-missing-indices/90696>\
**Category:** ℹ️ Support\
**Tags:** database, nc19\
**Created:** [August 27, 2020, 8:26am UTC](https://help.nextcloud.com/t/help-with-occ-db-add-missing-indices/90696 "2020-08-27T08:26:35Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alar\_East](https://help.nextcloud.com/user_avatar/help.nextcloud.com/alar_east/32/19484_2.png) [@Alar\_East](https://help.nextcloud.com/u/Alar_East)\
**Post date:** [August 27, 2020, 8:26am UTC](https://help.nextcloud.com/t/help-with-occ-db-add-missing-indices/90696/1 "2020-08-27T08:26:36Z")

</div>

hi,

after nextcloud update 19.0.1 i have error: Missing index “properties\_path\_index” in table “oc\_properties”.

If i sudo ae php occ db:add-missing-indices then i get error: PHP Parse error: syntax error, unexpected ‘class’ (T\_CLASS), expecting identifier (T\_STRING) or variable (T\_VARIABLE) or ‘{’ or ‘$’ in /media/aecloud/nextcloud/console.php on line 97

PHP 7.3.0 (cli) (built: Aug 27 2020 10:29:21) ( NTS )  
Copyright © 1997-2018 The PHP Group  
Zend Engine v3.3.0-dev, Copyright © 1998-2018 Zend Technologies  
with the ionCube PHP Loader + ionCube24 v10.3.9, Copyright © 2002-2019, by ionCube Ltd.  
with SourceGuardian v11.4.1, Copyright © 2000-2020, by SourceGuardian Ltd.

---

<div class="post-metadata">

**Author:** ![elChupete](https://help.nextcloud.com/letter_avatar/elchupete/32/5_5575768a8748004e209b776fc1b2916d.png) [@elChupete](https://help.nextcloud.com/u/elChupete)\
**Post date:** [August 30, 2020, 1:38pm UTC](https://help.nextcloud.com/t/help-with-occ-db-add-missing-indices/90696/2 "2020-08-30T13:38:28Z")

</div>

+1 same error here. Any solution?

---

<div class="post-metadata">

**Author:** ![chuchyeltronco](https://help.nextcloud.com/user_avatar/help.nextcloud.com/chuchyeltronco/32/29101_2.png) [@chuchyeltronco](https://help.nextcloud.com/u/chuchyeltronco)\
**Post date:** [September 17, 2020, 9:00pm UTC](https://help.nextcloud.com/t/help-with-occ-db-add-missing-indices/90696/3 "2020-09-17T21:00:41Z")

</div>

Hi,  
after nextcloud update 19.0.3 \* The database is missing some indexes. Due to the fact that adding indexes on big tables could take some time they were not added automatically. By running “occ db:add-missing-indices” those missing indexes could be added manually while the instance keeps running. Once the indexes are added queries to those tables are usually much faster.

- Missing index “properties\_path\_index” in table “oc\_properties”.
- The database is missing some optional columns. Due to the fact that adding columns on big tables could take some time they were not added automatically when they can be optional. By running “occ db:add-missing-columns” those missing columns could be added manually while the instance keeps running. Once the columns are added some features might improve responsiveness or usability.
  - Missing optional column “reference\_id” in table “oc\_comments”.

I Run this Command:

sudo -u www-data php /var/www/nextcloud/occ db:add-missing-indices  
sudo -u www-data php /var/www/nextcloud/occ db:add-missing-columns

And every is Ok Now.

---

<div class="post-metadata">

**Author:** ![nimkha](https://help.nextcloud.com/user_avatar/help.nextcloud.com/nimkha/32/25192_2.png) [@nimkha](https://help.nextcloud.com/u/nimkha)\
**Post date:** [October 7, 2020, 10:59pm UTC](https://help.nextcloud.com/t/help-with-occ-db-add-missing-indices/90696/4 "2020-10-07T22:59:12Z")

</div>

This also worked for me

---

<div class="post-metadata">

**Author:** ![Miguel\_VB](https://help.nextcloud.com/user_avatar/help.nextcloud.com/miguel_vb/32/27225_2.png) [@Miguel\_VB](https://help.nextcloud.com/u/Miguel_VB)\
**Post date:** [November 4, 2020, 7:32am UTC](https://help.nextcloud.com/t/help-with-occ-db-add-missing-indices/90696/5 "2020-11-04T07:32:07Z")

</div>

Thanks, its the best solution for my problem 😘 👍  
Nextcloud 19.0.4

---

<div class="post-metadata">

**Author:** ![andreasbecker](https://help.nextcloud.com/user_avatar/help.nextcloud.com/andreasbecker/32/32686_2.png) [@andreasbecker](https://help.nextcloud.com/u/andreasbecker)\
**Post date:** [December 21, 2020, 12:59pm UTC](https://help.nextcloud.com/t/help-with-occ-db-add-missing-indices/90696/6 "2020-12-21T12:59:35Z")

</div>

In case you’re on shared hosting maybe the follow SQL statements will help you to fix the problem:

```
ALTER TABLE `oc_properties` ADD INDEX `properties_path_index` (`userid`, `propertypath`) USING BTREE;
ALTER TABLE `oc_comments` ADD `reference_id` VARCHAR(64) NULL DEFAULT NULL;
ALTER TABLE `oc_filecache_extended` MODIFY `fileid` BIGINT(20) UNSIGNED NOT NULL;
```

---

<div class="post-metadata">

**Author:** ![Tex247](https://help.nextcloud.com/letter_avatar/tex247/32/5_5575768a8748004e209b776fc1b2916d.png) [@Tex247](https://help.nextcloud.com/u/Tex247)\
**Post date:** [October 18, 2021, 4:22pm UTC](https://help.nextcloud.com/t/help-with-occ-db-add-missing-indices/90696/9 "2021-10-18T16:22:02Z")

</div>

For Nextcloud on Unraid, I used this in a terminal window and it worked:

docker exec -it nextcloud occ db:add-missing-indices  
docker exec -it nextcloud occ db:add-missing-columns

---

<div class="post-metadata">

**Author:** ![GregLorenni](https://help.nextcloud.com/letter_avatar/greglorenni/32/5_5575768a8748004e209b776fc1b2916d.png) [@GregLorenni](https://help.nextcloud.com/u/GregLorenni)\
**Post date:** [November 13, 2021, 7:10pm UTC](https://help.nextcloud.com/t/help-with-occ-db-add-missing-indices/90696/10 "2021-11-13T19:10:03Z")

</div>

Much appreciated!

---

<div class="post-metadata">

**Author:** ![vuli](https://help.nextcloud.com/letter_avatar/vuli/32/5_5575768a8748004e209b776fc1b2916d.png) [@vuli](https://help.nextcloud.com/u/vuli)\
**Post date:** [August 10, 2022, 12:47pm UTC](https://help.nextcloud.com/t/help-with-occ-db-add-missing-indices/90696/11 "2022-08-10T12:47:10Z")

</div>

anyone know command for Umbrel?

---

<div class="post-metadata">

**Author:** ![robust322](https://help.nextcloud.com/letter_avatar/robust322/32/5_5575768a8748004e209b776fc1b2916d.png) [@robust322](https://help.nextcloud.com/u/robust322)\
**Post date:** [June 8, 2024, 4:23pm UTC](https://help.nextcloud.com/t/help-with-occ-db-add-missing-indices/90696/12 "2024-06-08T16:23:02Z")

</div>

Thank you so much…it worked!!!

---

<div class="post-metadata">

**Author:** ![jda](https://help.nextcloud.com/letter_avatar/jda/32/5_5575768a8748004e209b776fc1b2916d.png) [@jda](https://help.nextcloud.com/u/jda)\
**Post date:** [July 21, 2024, 4:18pm UTC](https://help.nextcloud.com/t/help-with-occ-db-add-missing-indices/90696/13 "2024-07-21T16:18:49Z")

</div>

For nextcloud on unraid server!!  
Enter the command in the Unraid ssh terminal. Not in the Nextcloud ssh Terminal!

---

<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:** [January 16, 2025, 9:20am UTC](https://help.nextcloud.com/t/help-with-occ-db-add-missing-indices/90696/14 "2025-01-16T09:20:12Z")

</div>


