Coder Social home page Coder Social logo

mysqladvisor / mysqladvisor Goto Github PK

View Code? Open in Web Editor NEW
85.0 3.0 23.0 20.33 MB

sql索引审查,索引建议; 如有意见或建议可以加群或emailto:[email protected]

License: GNU General Public License v2.0

CMake 1.44% C 66.62% Perl 0.08% Makefile 6.01% C++ 22.33% Roff 0.23% Batchfile 0.02% Shell 0.07% Objective-C 1.18% Pascal 0.29% Yacc 1.72%
mysql advisor ops sqlreview sql-injection sql

mysqladvisor's Introduction

一、简介

MySQLAdvisor是原SQLAdvisor项目转移到此,原先由美团点评公司技术工程部DBA团队(北京)开发维护的一个分析SQL给出索引优化建议的工具,现在由社区进行维护、迭代更新。它基于MySQL原生态词法解析,结合分析SQL中的where条件、聚合条件、多表Join关系 给出索引优化建议。目前SQLAdvisor在美团点评内部广泛应用,公司内部对SQLAdvisor的开发全面转到github上,开源和内部使用保持一致

主要功能:输出SQL索引优化建议

二、MySQLAdvisor详细说明

  1. MySQLAdvisor快速入门教程
  2. MySQLAdvisor架构和实践
  3. MySQLAdvisor release notes
  4. MySQLAdvisor开发规范
  5. FAQ

三、Changelog

增加了可以按照分号分隔分析多条sql的功能;

修复了部分bug;

四、MySQLAdvisor的需求及Bug反馈方式

如果用户在实际的应用场景中对MySQLAdvisor有新的功能需求,或者在使用MySQLAdvisor的过程中发现了bug,在github上进行交流或是PullRequest,也可以在讨论组/群进行反馈,我们会及时维护。

QQ群号:947480182

QQ

mysqladvisor's People

Contributors

longxuegang avatar nwsuafzq avatar tsthght avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

mysqladvisor's Issues

sql存在多数据库时,报【错误日志:Table 'db1.tableA' doesn't exist】错误

sql

SELECT * FROM `db2`.`tableA` AS a 
LEFT JOIN `db1`.`tableB` AS b ON a.company_code = b.CompanyCode 
WHERE a.company_code = 'xxx' AND a.company_type = '1'

具体日志(对关键信息做了替换)

/data/sqladvisor/SQLAdvisor-master/sqladvisor/sqladvisor -h xxx -P 3306 -u xxx -p xxx -d db1 -q 
"SELECT * FROM \`db2\`.\`tableA\` AS a 
LEFT JOIN \`db1\`.\`tableB\` AS b ON a.company_code = b.CompanyCode 
WHERE a.company_code = 'xxx' AND a.company_type = '1'" -v 1
2022-09-29 17:20:47 24980 [Note] 第1步: 对SQL解析优化之后得到的SQL:select `*` AS `*` 
from (`db2`.`tableA` `a` left join `db1`.`tableB` `b` on((`a`.`company_code` = `b`.`CompanyCode`))) 
where ((`a`.`company_code` = 'xxx') and (`a`.`company_type` = '1'))

2022-09-29 17:20:47 24980 [Note] 第2步:开始解析where中的条件:(`a`.`company_code` = 'xxx')

2022-09-29 17:20:47 24980 [Note] show index from tableA

2022-09-29 17:20:47 24980 [Note] show table status like 'table'

2022-09-29 17:20:47 24980 [Note] select count(*) from ( select `company_code` from `tableA` FORCE INDEX( PRIMARY ) order by company_id DESC limit 1234) `a` where (`a`.`company_code` = 'xxx')

2022-09-29 17:20:47 24980 [Note] 第3步:表tableA的行数:1234,limit行数:1234,得到where条件中(`a`.`company_code` = 'xxx')的选择度:1234

2022-09-29 17:20:47 24980 [Note] 第4步:开始解析where中的条件:(`a`.`company_type` = '1')

2022-09-29 17:20:47 24980 [Note] show index from tableA

2022-09-29 17:20:47 24980 [Note] show table status like 'tableA'

2022-09-29 17:20:47 24980 [Note] select count(*) from ( select `company_type` from `tableA` FORCE INDEX( PRIMARY ) order by company_id DESC limit 1234) `a` where (`a`.`company_type` = '1')

2022-09-29 17:20:47 24980 [Note] 第5步:表tableA的行数:1234,limit行数:1234,得到where条件中(`a`.`company_type` = '1')的选择度:1

2022-09-29 17:20:47 24980 [Note] 第6步:开始解析join on条件:a.company_code=b.CompanyCode

2022-09-29 17:20:47 24980 [Note] 第7步:开始选择驱动表,一共有1个候选驱动表

2022-09-29 17:20:47 24980 [Note] explain select * from tableA as a where (`a`.`company_code` = 'xxx')

2022-09-29 17:20:47 24980 [Note] 第8步:SQLAdvisor结束!错误日志:Table 'db1.tableA' doesn't exist

Segmentation fault (core dumped)

工具只能优化SELECT XXX FROM XXX的简单SQL?只要稍微麻烦点就core dump,弱爆了
2021-08-26 00:14:44 1808 [Note] 第12步:开始选择驱动表,一共有3个候选驱动表

2021-08-26 00:14:44 1808 [Note] explain select * from hmd_type

Segmentation fault (core dumped)

连表查询

/sqladvisor -u xx -p xx -P 3306 -h xxx -d sms -q 'SELECT d.id,a.sms_id,a.customer_id,d.phone,d.send_state,d.fail_msg,a.send_time FROM sms_record_detail d LEFT JOIN sms_record a on a.sms_id=d.sms_id WHERE d.create_time between "2022-10-30 00:00:00" and "2022-10-31 14:36:15" and a.app_id="eIfpuFBf"' -v 1
2022-10-31 16:58:56 625533 [Note] 第1步: 对SQL解析优化之后得到的SQL:select had some error

2022-10-31 16:58:56 625533 [Note] 第2步:开始解析join on条件:a.sms_id=d.sms_id

2022-10-31 16:58:56 625533 [Note] 第3步:开始选择驱动表,一共有1个候选驱动表

2022-10-31 16:58:56 625533 [Note] explain select * from sms_record_detail

段错误 (核心已转储)
报错,不能分析出来

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.