MySQL troubles
See original GitHub issueAs mentioned in #476 I still have massive CPU load when using Bookmarks v4.0.5, Floccus v4.4.6, Nextcloud v20.0.1 in combination with syncing floccus
Here are some database insights:
MariaDB [nextcloud]> EXPLAIN SELECT `b`.`id`, `b`.`url`, `b`.`title`, `b`.`description`, `b`.`lastmodified`, `b`.`added`, `b`.`clickcount`, `b`.`last_preview`, `b`.`available`, `b`.`archived_file`, `b`.`user_id`, GROUP_CONCAT(`tree`.`parent_folder`) AS `folders`, GROUP_CONCAT(`t`.`tag`) AS `tags` FROM `oc_bookmarks` `b` LEFT JOIN `oc_bookmarks_tree` `tree` ON (`b`.`id` = `tree`.`id`) AND (`tree`.`type` = 'bookmark') LEFT JOIN `oc_bookmarks_tags` `t` ON `t`.`bookmark_id` = `b`.`id` LEFT JOIN `oc_bookmarks_tree` `tr` ON (`tr`.`id` = `b`.`id`) AND (`tr`.`type` = 'bookmark') LEFT JOIN `oc_bookmarks_shared_folders` `sf` ON `tr`.`parent_folder` = `sf`.`folder_id` LEFT JOIN `oc_bookmarks_tree` `tr2` ON (`tr2`.`id` = `tr`.`parent_folder`) AND (`tr2`.`type` = 'folder') LEFT JOIN `oc_bookmarks_shared_folders` `sf2` ON `tr2`.`parent_folder` = `sf`.`folder_id` WHERE (`b`.`user_id` = 'fabi') OR (`sf`.`user_id` = 'fabi') OR (`sf2`.`user_id` = 'fabi') GROUP BY `b`.`id`, `b`.`url`, `b`.`title`, `b`.`description`, `b`.`lastmodified`, `b`.`added`, `b`.`clickcount`, `b`.`last_preview`, `b`.`available`, `b`.`archived_file`, `b`.`user_id`, `b`.`id` ORDER BY `b`.`lastmodified` DESC, `b`.`id` ASC LIMIT 300
-> ;
+------+-------------+-------+-------+-------------------------------------------+-----------------------+---------+----------------------------------+------+--------------------------------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+------+-------------+-------+-------+-------------------------------------------+-----------------------+---------+----------------------------------+------+--------------------------------------------------------------+
| 1 | SIMPLE | b | ALL | IDX_3EE1CD04A76ED395,bookmarks_deadbyuser | NULL | NULL | NULL | 796 | Using temporary; Using filesort |
| 1 | SIMPLE | tree | ref | PRIMARY | PRIMARY | 90 | nextcloud.b.id,const | 1 | Using where; Using index |
| 1 | SIMPLE | t | ref | bookmark_tag | bookmark_tag | 9 | nextcloud.b.id | 1 | Using index |
| 1 | SIMPLE | tr | ref | PRIMARY | PRIMARY | 90 | nextcloud.b.id,const | 1 | Using where; Using index |
| 1 | SIMPLE | sf | ALL | bookmarks_shared_folder | NULL | NULL | NULL | 1 | Using where; Using join buffer (flat, BNL join) |
| 1 | SIMPLE | tr2 | ref | PRIMARY | PRIMARY | 90 | nextcloud.tr.parent_folder,const | 1 | Using where; Using index |
| 1 | SIMPLE | sf2 | index | NULL | bookmarks_shared_user | 1022 | NULL | 1 | Using where; Using index; Using join buffer (flat, BNL join) |
+------+-------------+-------+-------+-------------------------------------------+-----------------------+---------+----------------------------------+------+--------------------------------------------------------------+
MariaDB [nextcloud]> SHOW INDEX FROM oc_bookmarks;
+--------------+------------+----------------------+--------------+--------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+--------------+------------+----------------------+--------------+--------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| oc_bookmarks | 0 | PRIMARY | 1 | id | A | 796 | NULL | NULL | | BTREE | | |
| oc_bookmarks | 1 | IDX_3EE1CD04A76ED395 | 1 | user_id | A | 4 | NULL | NULL | | BTREE | | |
| oc_bookmarks | 1 | IDX_3EE1CD04DF091378 | 1 | last_preview | A | 2 | NULL | NULL | YES | BTREE | | |
| oc_bookmarks | 1 | bookmarks_modified | 1 | lastmodified | A | 796 | NULL | NULL | YES | BTREE | | |
| oc_bookmarks | 1 | bookmarks_deadbyuser | 1 | user_id | A | 4 | NULL | NULL | | BTREE | | |
| oc_bookmarks | 1 | bookmarks_deadbyuser | 2 | available | A | 4 | NULL | NULL | | BTREE | | |
| oc_bookmarks | 1 | bookmarks_dead | 1 | available | A | 2 | NULL | NULL | | BTREE | | |
+--------------+------------+----------------------+--------------+--------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
MariaDB [nextcloud]> SHOW INDEX FROM oc_bookmarks_tree;
+-------------------+------------+-------------------------+--------------+---------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+-------------------+------------+-------------------------+--------------+---------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| oc_bookmarks_tree | 0 | PRIMARY | 1 | id | A | 55116 | NULL | NULL | | BTREE | | |
| oc_bookmarks_tree | 0 | PRIMARY | 2 | type | A | 55116 | NULL | NULL | | BTREE | | |
| oc_bookmarks_tree | 0 | PRIMARY | 3 | parent_folder | A | 55116 | NULL | NULL | | BTREE | | |
| oc_bookmarks_tree | 1 | bookmarks_tree_parent | 1 | parent_folder | A | 27558 | NULL | NULL | | BTREE | | |
| oc_bookmarks_tree | 1 | bookmarks_tree_parent_i | 1 | parent_folder | A | 18372 | NULL | NULL | | BTREE | | |
| oc_bookmarks_tree | 1 | bookmarks_tree_parent_i | 2 | index | A | 55116 | NULL | NULL | | BTREE | | |
+-------------------+------------+-------------------------+--------------+---------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
6 rows in set (0.001 sec)
MariaDB [nextcloud]> SHOW INDEX FROM oc_bookmarks_tags;
+-------------------+------------+--------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+-------------------+------------+--------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| oc_bookmarks_tags | 0 | bookmark_tag | 1 | bookmark_id | A | 0 | NULL | NULL | YES | BTREE | | |
| oc_bookmarks_tags | 0 | bookmark_tag | 2 | tag | A | 0 | NULL | NULL | | BTREE | | |
+-------------------+------------+--------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
MariaDB [nextcloud]> SHOW INDEX FROM oc_bookmarks_shared_folders;
+-----------------------------+------------+-------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+-----------------------------+------------+-------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| oc_bookmarks_shared_folders | 0 | PRIMARY | 1 | id | A | 0 | NULL | NULL | | BTREE | | |
| oc_bookmarks_shared_folders | 1 | bookmarks_shared_user | 1 | user_id | A | 0 | NULL | NULL | | BTREE | | |
| oc_bookmarks_shared_folders | 1 | bookmarks_shared_folder | 1 | folder_id | A | 0 | NULL | NULL | | BTREE | | |
+-----------------------------+------------+-------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
MariaDB [nextcloud]> SHOW variables like "%buffer%";
+-------------------------------------+----------------+
| Variable_name | Value |
+-------------------------------------+----------------+
| aria_pagecache_buffer_size | 134217728 |
| aria_sort_buffer_size | 268434432 |
| bulk_insert_buffer_size | 16777216 |
| innodb_buffer_pool_chunk_size | 134217728 |
| innodb_buffer_pool_dump_at_shutdown | ON |
| innodb_buffer_pool_dump_now | OFF |
| innodb_buffer_pool_dump_pct | 25 |
| innodb_buffer_pool_filename | ib_buffer_pool |
| innodb_buffer_pool_instances | 1 |
| innodb_buffer_pool_load_abort | OFF |
| innodb_buffer_pool_load_at_startup | ON |
| innodb_buffer_pool_load_now | OFF |
| innodb_buffer_pool_size | 1073741824 |
| innodb_change_buffer_max_size | 25 |
| innodb_change_buffering | all |
| innodb_log_buffer_size | 8388608 |
| innodb_sort_buffer_size | 1048576 |
| join_buffer_size | 262144 |
| join_buffer_space_limit | 2097152 |
| key_buffer_size | 134217728 |
| mrr_buffer_size | 262144 |
| myisam_sort_buffer_size | 536870912 |
| net_buffer_length | 16384 |
| preload_buffer_size | 32768 |
| read_buffer_size | 2097152 |
| read_rnd_buffer_size | 1048576 |
| sort_buffer_size | 4194304 |
| sql_buffer_result | OFF |
+-------------------------------------+----------------+
28 rows in set (0.003 sec)
MariaDB [nextcloud]> SHOW variables like "%table_size%";
+-----------------------+----------------------+
| Variable_name | Value |
+-----------------------+----------------------+
| max_heap_table_size | 33554432 |
| tmp_disk_table_size | 18446744073709551615 |
| tmp_memory_table_size | 33554432 |
| tmp_table_size | 33554432 |
+-----------------------+----------------------+
4 rows in set (0.001 sec)
_Originally posted by @faaaaabi in https://github.com/marcelklehr/floccus/issues/476#issuecomment-726923253_
Issue Analytics
- State:
- Created 3 years ago
- Comments:17 (11 by maintainers)
Top Results From Across the Web
2.10.2.1 Troubleshooting Problems Starting the MySQL Server
2.10.2.1 Troubleshooting Problems Starting the MySQL Server · Check the error log to see why the server does not start. · Specify any...
Read more >How To Troubleshoot Issues in MySQL - DigitalOcean
We'll go over some of the issues that many MySQL users encounter and provide guidance for troubleshooting specific problems. We will also include...
Read more >Useful Tips to Troubleshoot Common Errors in MySQL - Tecmint
This article explains some useful tips on how to troubleshoot problems and common errors in MySQL database and how to determine the causes ......
Read more >How to fix common problems with MySQL databases - UpCloud
How to fix common problems with MySQL databases · Check that the service is running. If your website cannot connect to your database,...
Read more >MySQL Troubleshooting [Book] - O'Reilly
Written by a principal technical support engineer at Oracle, MySQL Troubleshooting provides the background, tools, and expert steps for solving problems ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
the tree table should not grow much larger than the bookmarks table, except for cases where the same bookmark is in multiple folders. There is now a repair step that should get rid of all superfluous tree entries.
Hey there!
It’s been a while, but I’ve finally uncovered the reason for this peculiar behavior and will release a patch to the bookmarks app shortly: https://github.com/nextcloud/bookmarks/pull/1608
The problem was that the query in question needs to load all bookmarks in the db initially since they could all potentially be viewed by the current user (if they are shared with the current user, which however, will only be discovered after a JOIN). My solution, now, is to initially only load bookmarks by users that have shared bookmarks with the current user, which is still not ideal, but should be a much smaller set than ALL.