Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

整体优化索引优化功能 #2128

Merged
merged 13 commits into from
Dec 8, 2023
Merged

整体优化索引优化功能 #2128

merged 13 commits into from
Dec 8, 2023

Conversation

winfredLIN
Copy link
Collaborator

@winfredLIN winfredLIN commented Dec 5, 2023

#2117

代码改动

  1. 删除了旧的索引优化代码
  2. 添加新的索引优化代码
  3. 为新的索引优化器,添加单元测试

如何实现

首先,实现了一个Optimizer,Optimizer基于SQL语句、执行计划等信息判断SQL语句对应的表是否需要添加索引,如果不需要,返回上层,不给出建议,如果需要,将载入给出索引建议的基本的条件,然后调用AdvisorVisitor给出建议。

第二,实现了五种Advisor,Advisor会根据抽象语法节点、SQL上下文、库表信息等信息给出针对具体SQL和具体表的索引优化建议。Advisor和Visitor组成了AdvisorVisitor,AdvisorVisitor将访问SQL的抽象语法树,对对应的节点调用对应的Advisor,给出相应的建议。

实现的功能有

  • 根据SELECT语句给出三星索引建议
  • 根据JOIN语句,给出建议:...对JOIN语句被驱动表关联字段添加索引...
  • 根据WHERE等值条件中对列使用的函数给出建议:...根据系统版本,添加函数索引,或在虚拟列上添加索引...
  • 根据最值函数,给出建议:...利用索引有序性质找到最值...
  • 根据前缀匹配模式,给出建议:...使用了前缀模式匹配,在数据量大的时候,可以建立翻转函数索引...

@winfredLIN winfredLIN requested a review from sjjian December 5, 2023 10:35
@sjjian sjjian merged commit 2419692 into release-2.9999.x Dec 8, 2023
3 checks passed
@sjjian sjjian deleted the index-optimize branch December 8, 2023 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants