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

db2不兼容EXPLAIN #3

Open
andream7 opened this issue Aug 11, 2021 · 1 comment
Open

db2不兼容EXPLAIN #3

andream7 opened this issue Aug 11, 2021 · 1 comment

Comments

@andream7
Copy link
Owner

andream7 commented Aug 11, 2021

image
如果"@Explain": true ,也就是开启性能分析,将会报错。

生成的语句如下:

EXPLAIN SELECT * FROM "DB2ADMIN"."apijson_user" WHERE  (  ("id" = 82007)  )  ORDER BY "id" LIMIT 1

该语句报错,去掉EXPLAIN后可以正常运行。

@andream7 andream7 changed the title db2不兼容EXPLAIN语法,修改相关源码 db2不兼容EXPLAIN Aug 21, 2021
@andream7
Copy link
Owner Author

通过查阅相关资料,db2好像是不支持这个语法,但是可以通过以下方式使用Explain。
设定 Explain 模式,执行SQL,结束Explain。

1. db2 connect
2. db2 set current explain mode explain
3. db2 -tvf sql.txt
4. db2 set current explain mode no

之后可以选用 db2exfmt 命令格式化输出:

5. db2exfmt -d sample -o sql.explain.txt
6. cat sql.explain.txt

Repository owner deleted a comment Feb 1, 2024
Repository owner deleted a comment from dwcooper Feb 23, 2024
Repository owner deleted a comment from DrakoAI Feb 23, 2024
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

No branches or pull requests

1 participant