Skip to content

for the DB ot pick an index specify the object_type - #19281

Merged
rullzer merged 1 commit into
masterfrom
fix/noid/get-unread-comments-with-indexes
Feb 3, 2020
Merged

for the DB ot pick an index specify the object_type#19281
rullzer merged 1 commit into
masterfrom
fix/noid/get-unread-comments-with-indexes

Conversation

@blizzz

@blizzzblizzz commented Feb 3, 2020

Copy link
Copy Markdown
Member

The indices in the comments DB include the whole object, consisting of a type and its ID. The queries did not take the type in account (well, not everywhere), which used some subqueries to run expensive without using the index.

Before:

+----+-------------+-------+------------+-------+-------------------------------------------------------------------------------------------------------------------+-----------------------+---------+-------+------+----------+-----------------------------------------------------------------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+-------+------------+-------+-------------------------------------------------------------------------------------------------------------------+-----------------------+---------+-------+------+----------+-----------------------------------------------------------------+
| 1 | SIMPLE | f | NULL | ref | PRIMARY,fs_storage_path_hash,fs_parent_name_hash,fs_storage_mimetype,fs_storage_mimepart,fs_storage_size,fs_mtime | fs_parent_name_hash | 8 | const | 1 | 100.00 | Using index; Using temporary; Using filesort |
| 1 | SIMPLE | c | NULL | index | NULL | comments_object_index | 522 | NULL | 427 | 55.00 | Using where; Using index; Using join buffer (Block Nested Loop) |
| 1 | SIMPLE | m | NULL | ALL | NULL | NULL | NULL | NULL | 23 | 8.80 | Using where; Using join buffer (Block Nested Loop) |
+----+-------------+-------+------------+-------+-------------------------------------------------------------------------------------------------------------------+-----------------------+---------+-------+------+----------+-----------------------------------------------------------------+

Now

+----+-------------+-------+------------+------+-------------------------------------------------------------------------------------------------------------------+------------------------------+---------+-------------------------------+------+----------+-----------------------------------------------------------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+-------+------------+------+-------------------------------------------------------------------------------------------------------------------+------------------------------+---------+-------------------------------+------+----------+-----------------------------------------------------------+
| 1 | SIMPLE | f | NULL | ref | PRIMARY,fs_storage_path_hash,fs_parent_name_hash,fs_storage_mimetype,fs_storage_mimepart,fs_storage_size,fs_mtime | fs_parent_name_hash | 8 | const | 1 | 100.00 | Using where; Using index; Using temporary; Using filesort |
| 1 | SIMPLE | c | NULL | ref | comments_object_index | comments_object_index | 258 | const | 20 | 100.00 | Using where; Using index |
| 1 | SIMPLE | m | NULL | ref | comments_marker_object_index | comments_marker_object_index | 516 | const,nextcloud.c.object_id | 1 | 16.00 | Using where |
+----+-------------+-------+------------+------+-------------------------------------------------------------------------------------------------------------------+------------------------------+---------+-------------------------------+------+----------+-----------------------------------------------------------+

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>

@ChristophWurstChristophWurst left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense! Good catch!

@blizzz

Copy link
Copy Markdown
MemberAuthor

/backport to stable18

@blizzz

Copy link
Copy Markdown
MemberAuthor

/backport to stable17

@blizzz

Copy link
Copy Markdown
MemberAuthor

/backport to stable16

@blizzzblizzz added 4. to release Ready to be released and/or waiting for tests to finish and removed 3. to review Waiting for reviews labels Feb 3, 2020
@rullzer
rullzer merged commit 4503cff into masterFeb 3, 2020
@rullzer
rullzer deleted the fix/noid/get-unread-comments-with-indexes branch February 3, 2020 20:23
@backportbot-nextcloud

Copy link
Copy Markdown

backport to stable18 in #19283

@backportbot-nextcloud

Copy link
Copy Markdown

backport to stable17 in #19284

@backportbot-nextcloud

Copy link
Copy Markdown

backport to stable16 in #19285

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4. to releaseReady to be released and/or waiting for tests to finishbugfeature: comments

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@blizzz@ChristophWurst@skjnldsv@rullzer