# Database performance issue

**URL:** <https://help.nextcloud.com/t/database-performance-issue/19583>\
**Category:** ℹ️ Support\
**Created:** [August 14, 2017, 9:41am UTC](https://help.nextcloud.com/t/database-performance-issue/19583 "2017-08-14T09:41:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![muppeth](https://help.nextcloud.com/user_avatar/help.nextcloud.com/muppeth/32/3504_2.png) [@muppeth](https://help.nextcloud.com/u/muppeth)\
**Post date:** [August 14, 2017, 9:41am UTC](https://help.nextcloud.com/t/database-performance-issue/19583/1 "2017-08-14T09:41:46Z")

</div>

Hi guys,  
I wasnt sure if it’s a general bug or something on my instance, so I didn’t create an issue on github yet. I was hoping someone could help me debug, the issue I’m having. I’m struggling with databse performance. I noticed that addressbook queries are ending up in slow-query log. I’m also seeing a lot of: `Joins performed without indexes: 1141540` when running mysqltunner.  
Basically the moment anyone goes to Contact app or syncs new contacts my CPU goes through the roof (seeing even picking at 500% on htop). Disk IO is low so it’s not related to writes. I’ve tested it on test instance with default my.cnf mariadb settings with all other apps disabled (same db).

Checking slow query like (usually addressbook related queries):  
`explain SELECT`id`,`uri`,`lastmodified`,`etag`,`size`,`carddata`FROM`oc\_cards`WHERE`addressbookid`= '1543';`  
the result is:

```auto
+------+-------------+----------+------+---------------+------+---------+------+-------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+------+-------------+----------+------+---------------+------+---------+------+-------+-------------+
| 1 | SIMPLE | oc_cards | ALL | NULL | NULL | NULL | NULL | 36593 | Using where |
+------+-------------+----------+------+---------------+------+---------+------+-------+-------------+

```

Any hints, ideas?

---

<div class="post-metadata">

**Author:** ![tflidd](https://help.nextcloud.com/letter_avatar/tflidd/32/6_449c533f586939b6e5f246632a46421f.png) [@tflidd](https://help.nextcloud.com/u/tflidd)\
**Post date:** [August 15, 2017, 9:57pm UTC](https://help.nextcloud.com/t/database-performance-issue/19583/2 "2017-08-15T21:57:53Z")

</div>

You have 36593 entries in your addressbook?

Do you use redis and/or apcu for caching? This reduces the load on your database.

---

<div class="post-metadata">

**Author:** ![muppeth](https://help.nextcloud.com/user_avatar/help.nextcloud.com/muppeth/32/3504_2.png) [@muppeth](https://help.nextcloud.com/u/muppeth)\
**Post date:** [August 15, 2017, 11:08pm UTC](https://help.nextcloud.com/t/database-performance-issue/19583/3 "2017-08-15T23:08:37Z")

</div>

Yes. I use both redis and apcu for caching. At the moment my contacts size is:  
`select COUNT(*) from oc_cards;` - 43615  
`oc_addressbooks;` - 2099  
`oc_adressbookchanges;` - 426194  
`oc_cards_properties ;` - 203849

Mysqltunner yells there is 6570722 joins performed without indexes atm.  
I’m worndering if that’s normal since the developer guide mentions to always use indexes. Most of the queries in slow log are like:

```auto
SELECT `id`, `uri`, `lastmodified`, `etag`, `size`, `carddata` FROM `oc_cards` WHERE (`addressbookid` = '1493') AND (`uri` = '.4caa34af-99af-4a3b-9e24-5c2bc1d02342.vcf') 

```

I’ve moved that DB to test a server where only one user was logged in, and the results were pretty much the same. When using calendars, activities, db is responsive and quite fast. The moment I go to contacts the cpu grind starts. Creating/deleting contact takes about 4 sec. to complete.

If there is anything I should check or troubleshoot let me know. I need suggestions or hints to change my perspective on the issue, Maybe I’m missing something obvious. Atm I cache the entire database (4GB) in RAM with `innodb_buffer_pool_size`, but that seem to not improve much. My `innodb_log_file_size` is set quite high (512MB) so there is not that much disk IO. Mysqltunner suggest to crank up `join_buffer_size` which I did to 2MB, but seems like it could be easily 32MB and mysqltuner would suggest increasing (should I?).

---

<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 2, 2024, 2:18pm UTC](https://help.nextcloud.com/t/database-performance-issue/19583/4 "2024-12-02T14:18:51Z")

</div>



---

<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 4, 2024, 1:46pm UTC](https://help.nextcloud.com/t/database-performance-issue/19583/5 "2024-12-04T13:46:26Z")

</div>


