未加星标

More on MyRocks Performance for Bug #68079 Case

字体大小 | |
[数据库(mysql) 所属分类 数据库(mysql) | 发布者 店小二05 | 时间 2017 | 作者 红领巾 ] 0人收藏点击收藏

Myprevious post on MyRocks was intended to provide some background details for a couple of slides for my FOSDEM talk on profiling mysql. The results and performance demonstrated by MyRocks vs InnoDB from MySQL 5.7.17 were not really important to show how perf helps to understand where the time was spent while executing of one specific query vs the other (with the same results, but different plan), but they still caused a lot of comments from people who care, so I decided to double check and clarify few more details.

First of all, it wasnoted that one may get the same execution plan for both queries (even in INNER JOIN case we may end up with filesort and access only via PRIMARY keys), like this:

# bin/mysql test -e 'explain select count(*), category from task inner join incident on task.sys_id=incident.sys_id group by incident.category\G'

*************************** 1. row ***************************

id: 1

select_type: SIMPLE

table: task

type: index

possible_keys: PRIMARY

key: PRIMARY

key_len: 96

ref: NULL

rows: 8092

Extra: Using index; Using temporary; Using filesort

*************************** 2. row ***************************

id: 1

select_type: SIMPLE

table: incident

type: eq_ref

possible_keys: PRIMARY,incident_category

key: PRIMARY

key_len: 96

ref: test.task.sys_id

rows: 1

Extra: NULL

Indeed, I've ended up with this plan easily, sometimes, after executing ANALYZE for the tables involved. But this was not always the case (here we see for InnoDB) and next ANALYZE or OPTIMIZE may change the plan:

mysql> analyze table task;

+-----------+---------+----------+----------+

| Table | Op | Msg_type | Msg_text |

+-----------+---------+----------+----------+

| test.task | analyze | status | OK |

+-----------+---------+----------+----------+

1 row in set (0.06 sec)

mysql> analyze table incident;

+---------------+---------+----------+----------+

| Table | Op | Msg_type | Msg_text |

+---------------+---------+----------+----------+

| test.incident | analyze | status | OK |

+---------------+---------+----------+----------+

1 row in set (0.15 sec)

mysql> show table status like 'task'\G

*************************** 1. row ***************************

Name: task

Engine: InnoDB

Version: 10

Row_format: Dynamic

Rows: 8452

Avg_row_length: 60

Data_length: 507904

Max_data_length: 0

Index_length: 0

Data_free: 0

Auto_increment: NULL

Create_time: 2017-01-31 12:00:38

Update_time: NULL

Check_time: NULL

Collation: utf8_general_ci

Checksum: NULL

Create_options:

Comment:

1 row in set (0.00 sec)

mysql> show table status like 'incident'\G

*************************** 1. row ***************************

Name: incident

Engine: InnoDB

Version: 10

Row_format: Dynamic

Rows: 7786

Avg_row_length: 204

Data_length: 1589248

Max_data_length: 0

Index_length: 507904

Data_free: 4194304

Auto_increment: NULL

Create_time: 2017-01-31 12:00:35

Update_time: NULL

Check_time: NULL

Collation: utf8_general_ci

Checksum: NULL

Create_options:

Comment:

1 row in set (0.00 sec)

mysql> explain select count(*), category from task inner join incident on task.sys_id=incident.sys_id group by incident.category;

+----+-------------+----------+------------+--------+---------------------------+-------------------+---------+----------------------+------+----------+-------------+

| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |

+----+-------------+----------+------------+--------+---------------------------+-------------------+---------+----------------------+------+----------+-------------+

| 1 | SIMPLE | incident | NULL | index | PRIMARY,incident_category | incident_category | 123 | NULL | 7786 | 100.00 | Using index |

| 1 | SIMPLE | task | NULL | eq_ref | PRIMARY | PRIMARY | 96 | test.incident.sys_id | 1 | 100.00 | Using index |

+----+-------------+----------+------------+--------+---------------------------+-------------------+---------+----------------------+------+----------+-------------+

2 rows in set, 1 warning (0.02 sec)

Surely I can always force the plan needed, this way or that:

mysql> explain select count(*), category from task inner join incident force index(primary) on task.sys_id=incident.sys_id group by incident.category;

+----+-------------+----------+------------+--------+---------------------------+---------+---------+------------------+------+----------+----------------------------------------------+

| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |

+----+-------------+----------+------------+--------+---------------------------+---------+---------+------------------+------+----------+----------------------------------------------+

| 1 | SIMPLE | task | NULL | index | PRIMARY | PRIMARY | 96 | NULL | 8452 | 100.00 | Using index; Using temporary; Using filesort |

| 1 | SIMPLE | incident | NULL | eq_ref | PRIMARY,incident_category | PRIMARY | 96 | test.task.sys_id | 1 | 100.00 | NULL |

+----+-------------+----------+------------+--------+---------------------------+---------+---------+------------------+------+----------+----------------------------------------------+

2 rows in set, 1 warning (0.00 sec)

mysql> explain select count(*), category from task straight_join incident on task.sys_id=incident.sys_id group by incident.category;

+----+-------------+----------+------------+--------+---------------------------+---------+---------+------------------+------+----------+----------------------------------------------+

| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |

+----+-------------+----------+------------+--------+---------------------------+---------+---------+------------------+------+----------+----------------------------------------------+

| 1 | SIMPLE | task | NULL | index | PRIMARY | PRIMARY | 96 | NULL | 8452 | 100.00 | Using index; Using temporary; Using filesort |

| 1 | SIMPLE | incident | NULL | eq_ref | PRIMARY,incident_category | PRIMARY | 96 | test.task.sys_id | 1 | 100.00 | NULL |

+----+-------------+----------+------------+--------+---------------------------+---------+---------+------------------+------+----------+----------------------------------------------+

2 rows in set, 1 warning (0.00 sec)

本文数据库(mysql)相关术语:navicat for mysql mysql workbench mysql数据库 mysql 存储过程 mysql安装图解 mysql教程 mysql 管理工具

主题: InnoDBSQLMySQLRIMRYTIOPT
分页:12
转载请注明
本文标题:More on MyRocks Performance for Bug #68079 Case
本站链接:http://www.codesec.net/view/531711.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 数据库(mysql) | 评论(0) | 阅读(43)