Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#2117
代码改动
如何实现
首先,实现了一个Optimizer,Optimizer基于SQL语句、执行计划等信息判断SQL语句对应的表是否需要添加索引,如果不需要,返回上层,不给出建议,如果需要,将载入给出索引建议的基本的条件,然后调用AdvisorVisitor给出建议。
第二,实现了五种Advisor,Advisor会根据抽象语法节点、SQL上下文、库表信息等信息给出针对具体SQL和具体表的索引优化建议。Advisor和Visitor组成了AdvisorVisitor,AdvisorVisitor将访问SQL的抽象语法树,对对应的节点调用对应的Advisor,给出相应的建议。
实现的功能有