Meituan-Dianping / SQLAdvisor

输入SQL,输出索引优化建议
GNU General Public License v2.0
5.58k stars 1.25k forks source link

Segmentation fault #3

Open wakaka2017 opened 7 years ago

wakaka2017 commented 7 years ago

1.OS version:CentOS release 6.5 (Final) MySQL version:5.7.16-log

2.error 2017-03-10 14:41:26 18622 [Note] 第1步: 对SQL解析优化之后得到的SQL:select count(1) AS COUNT(1) from (mydb.archive a left join mydb.archive_detail ad on((a.id = ad.archive_id))) where (a.user_id = 231) 2017-03-10 14:41:26 18622 [Note] 第2步:开始解析where中的条件:(a.user_id = 231) 2017-03-10 14:41:26 18622 [Note] show index from archive 2017-03-10 14:41:26 18622 [Note] show table status like 'archive' 2017-03-10 14:41:26 18622 [Note] select count() from ( select user_id from archive FORCE INDEX( PRIMARY ) order by id DESC limit 4) a where (a.user_id = 231)
2017-03-10 14:41:26 18622 [Note] 第3步:表archive的行数:9,limit行数:4,得到where条件中(a.user_id = 231)的选择度:4 2017-03-10 14:41:26 18622 [Note] 第4步:开始解析join on条件:a.id=ad.archive_id 2017-03-10 14:41:26 18622 [Note] 第5步:开始选择驱动表,一共有1个候选驱动表 2017-03-10 14:41:26 18622 [Note] explain select
from archive Segmentation fault

3.table ddl CREATE TABLE archive ( id bigint(20) NOT NULL AUTO_INCREMENT, signed_summary_id bigint(20) DEFAULT NULL, user_id bigint(20) DEFAULT NULL, tilte varchar(200) DEFAULT NULL, archive_type int(11) DEFAULT NULL, archive_date date DEFAULT NULL, created1 bigint(20) DEFAULT NULL, created2 varchar(50) DEFAULT NULL, created_date datetime DEFAULT NULL, PRIMARY KEY (id) ) ENGINE=InnoDB AUTO_INCREMENT=270 DEFAULT CHARSET=utf8mb4;

CREATE TABLE archive_detail ( id bigint(20) NOT NULL AUTO_INCREMENT, archive_id bigint(20) DEFAULT NULL, archive_type int(11) DEFAULT NULL, archive_type_name varchar(20) DEFAULT NULL, content varchar(2000) DEFAULT NULL, pic varchar(200) DEFAULT NULL, voice varchar(2000) DEFAULT NULL, created_date datetime DEFAULT NULL, service_remark int(5) DEFAULT '0', PRIMARY KEY (id) ) ENGINE=InnoDB AUTO_INCREMENT=420 DEFAULT CHARSET=utf8mb4;

Zhifeiyu commented 7 years ago

同问

linmoyu commented 7 years ago

请问这个问题解决了吗, 我也碰到同样的问题

pandakll commented 7 years ago

关注这个问题

imuse2012 commented 7 years ago

同问

pandakll commented 7 years ago

工具基于mysql5.7的bug吧,5.6没问题

nbsky commented 7 years ago

同5.7也出现了

empo007 commented 6 years ago

这个问题我简单修改下代码可以不出现这个错误了:

把322行左右的下面文本: if ((row = mysql_fetch_row(result))) { result_set_count = atoi(row[EXPLAIN_ROWS]); } 修改为: if ((row = mysql_fetch_row(result))) { if (row[EXPLAIN_ROWS]!=NULL) { result_set_count = atoi(row[EXPLAIN_ROWS]); } }

leiyifang commented 6 years ago

好的,谢谢!

lei-yi-fang@163.com

From: empo007 Date: 2017-12-05 14:39 To: Meituan-Dianping/SQLAdvisor CC: Subscribed Subject: Re: [Meituan-Dianping/SQLAdvisor] Segmentation fault (#3) 这个问题我简单修改下代码可以不出现这个错误了: 把322行左右的下面文本: if ((row = mysql_fetch_row(result))) { result_set_count = atoi(row[EXPLAIN_ROWS]); } 修改为: if ((row = mysql_fetch_row(result))) { if (row[EXPLAIN_ROWS]!=NULL) { result_set_count = atoi(row[EXPLAIN_ROWS]); } } — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

jpfss commented 6 years ago

关注这个问题

jpfss commented 6 years ago

修改哪个文件?

shihuizhen commented 6 years ago

出现这个问题是因为mysql 5.7 的执行计划默认返回的字段和5.7 以前的不同。工具不能正常判断出执行计划范围的影响行数,所以报错。按照empo007 的方法改,虽然不出错了,但是也失去了针对join的进一步分析的功能。

jakehu commented 6 years ago

同样出现错误,持续关注中。Mysql环境 5.7

dev-zhangchenxi commented 4 years ago

同出现此问题 mysql5.7 上面改代码的方式验证有效