-
Notifications
You must be signed in to change notification settings - Fork 74
optimize: ddl operators don't need infoschema #771
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
base: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @Song-Quan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 此拉取请求旨在通过消除各种DDL和DCL操作以及SHOW COLUMNS/DESCRIBE语句对InfoSchema的不必要依赖,来优化其性能并降低开销。通过允许这些操作直接查询存储或使用其自身的验证机制,系统可以避免加载可能庞大的InfoSchema对象,从而实现更高效的执行。 Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
本次代码审查主要关注了为优化 DDL 操作而进行的修改,这些修改旨在减少对 InfoSchema 的依赖。整体来看,PR 的目标明确,实现方式合理。主要改动包括:
- 在
preprocess.go中为SHOW COLUMNS语句添加了新的标志,以在预处理阶段跳过表名解析。 - 在
executor/show.go中,修改了fetchShowColumns函数,使其直接从底层存储查询列的元数据,而不是依赖 InfoSchema。 - 在
server/submit_handler.go中,扩展了isQueryNeedInfoSchema函数,以识别更多可以绕过加载 InfoSchema 的 DDL 语句。 - 为
isQueryNeedInfoSchema函数添加了全面的单元测试,确保了逻辑的正确性。
这些改动是有效的,并且有对应的测试覆盖。我提出了一些小的建议,主要涉及代码风格和错误处理,以期提高代码的可读性和健壮性。
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
| if showStmt, ok := s.Stmt.(*ast.ShowStmt); ok && showStmt.Tp == ast.ShowColumns { | ||
| return false, nil | ||
| } | ||
| return true, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
针对其它需要infoSchema的场景,如果db/table过多,应该还是会很慢,会有业务影响吗?以及有改进思路吗
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
会有影响,可以考虑增加 cache 或者在加载 infoschema 的时候,如果 db 过多,就选择全表扫描。
这个可以后面再提 pr
当前使用了 InfoSchema 但是其实不需要的: