Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CSDN 技术社区
skill_tree_mysql
提交
ea9b0488
S
skill_tree_mysql
项目概览
CSDN 技术社区
/
skill_tree_mysql
通知
21
Star
0
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
skill_tree_mysql
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
ea9b0488
编写于
6月 08, 2022
作者:
M
Mars Liu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
profile and explain
上级
0f811a0f
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
206 addition
and
18 deletion
+206
-18
data/3.MySQL高阶/7.查询优化/1. SHOW STATUS/config.json
data/3.MySQL高阶/7.查询优化/1. SHOW STATUS/config.json
+8
-3
data/3.MySQL高阶/7.查询优化/1. SHOW STATUS/show_status.json
data/3.MySQL高阶/7.查询优化/1. SHOW STATUS/show_status.json
+8
-0
data/3.MySQL高阶/7.查询优化/1. SHOW STATUS/show_status.md
data/3.MySQL高阶/7.查询优化/1. SHOW STATUS/show_status.md
+30
-0
data/3.MySQL高阶/7.查询优化/2. SHOW PROFILE/config.json
data/3.MySQL高阶/7.查询优化/2. SHOW PROFILE/config.json
+8
-3
data/3.MySQL高阶/7.查询优化/2. SHOW PROFILE/show_profile.json
data/3.MySQL高阶/7.查询优化/2. SHOW PROFILE/show_profile.json
+8
-0
data/3.MySQL高阶/7.查询优化/2. SHOW PROFILE/show_profile.md
data/3.MySQL高阶/7.查询优化/2. SHOW PROFILE/show_profile.md
+35
-0
data/3.MySQL高阶/7.查询优化/3. EXPLAIN/config.json
data/3.MySQL高阶/7.查询优化/3. EXPLAIN/config.json
+9
-3
data/3.MySQL高阶/7.查询优化/3. EXPLAIN/explain.json
data/3.MySQL高阶/7.查询优化/3. EXPLAIN/explain.json
+8
-0
data/3.MySQL高阶/7.查询优化/3. EXPLAIN/explain.md
data/3.MySQL高阶/7.查询优化/3. EXPLAIN/explain.md
+82
-0
data/tree.json
data/tree.json
+10
-9
未找到文件。
data/3.MySQL高阶/7.查询优化/1. SHOW STATUS/config.json
浏览文件 @
ea9b0488
{
"node_id"
:
"mysql-3574b2e5c9ca475789d9d582d7726906"
,
"keywords"
:
[
"show status"
],
"keywords"
:
[
"show status"
],
"children"
:
[],
"export"
:
[],
"export"
:
[
"show_status.json"
],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
"group"
:
2
}
\ No newline at end of file
data/3.MySQL高阶/7.查询优化/1. SHOW STATUS/show_status.json
0 → 100644
浏览文件 @
ea9b0488
{
"type"
:
"code_options"
,
"author"
:
"ccat"
,
"source"
:
"show_status.md"
,
"notebook_enable"
:
false
,
"exercise_id"
:
"889fd9ebeda74ba2a4c90ee0d6c13f0d"
}
\ No newline at end of file
data/3.MySQL高阶/7.查询优化/1. SHOW STATUS/show_status.md
0 → 100644
浏览文件 @
ea9b0488
# SHOW STATUS
Goods 数据库近期在每日高峰时段很慢,Joe 想初步的查看一下数据库的工作状态,他应该执行:
## 答案
```
mysql
show global status;
```
## 选项
### A
```
mysql
show status;
```
### B
```
mysql
show session status;
```
### C
```
mysql
show local status;
```
data/3.MySQL高阶/7.查询优化/
3
. SHOW PROFILE/config.json
→
data/3.MySQL高阶/7.查询优化/
2
. SHOW PROFILE/config.json
浏览文件 @
ea9b0488
{
"node_id"
:
"mysql-f0b12126dd3e4be09010a308a822bc32"
,
"keywords"
:
[
"show profile"
],
"keywords"
:
[
"show profile"
],
"children"
:
[],
"export"
:
[],
"export"
:
[
"show_profile.json"
],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
"group"
:
2
}
\ No newline at end of file
data/3.MySQL高阶/7.查询优化/2. SHOW PROFILE/show_profile.json
0 → 100644
浏览文件 @
ea9b0488
{
"type"
:
"code_options"
,
"author"
:
"ccat"
,
"source"
:
"show_profile.md"
,
"notebook_enable"
:
false
,
"exercise_id"
:
"c785a28bb1474b1c8b9f3fab908041bf"
}
\ No newline at end of file
data/3.MySQL高阶/7.查询优化/2. SHOW PROFILE/show_profile.md
0 → 100644
浏览文件 @
ea9b0488
# SHOW PROFILE
数据分析组的几个分析查询很慢,希望 Joe 提供帮助,他准备查看一下这几条查询的 Profile 信息,应该:
1.
执行
`SET SESSION profiling = 1;`
打开 profile
2.
执行查询后,根据
`show profiles`
找到要剖分的查询id
3.
执行
`SHOW PROFILE FOR QUERY xxx;`
查看剖分信息
4.
执行
`SET SESSION profiling = 0;`
关闭 profile
## 答案
```
1, 2, 3, 4
```
## 选项
### A
```
2, 3
```
### B
```
1, 2, 3
```
### C
```
2, 3, 4
```
\ No newline at end of file
data/3.MySQL高阶/7.查询优化/
2
. EXPLAIN/config.json
→
data/3.MySQL高阶/7.查询优化/
3
. EXPLAIN/config.json
浏览文件 @
ea9b0488
{
"node_id"
:
"mysql-a42f617d4eb54aabbc649bdde4485117"
,
"keywords"
:
[
"explain"
],
"keywords"
:
[
"explain"
,
"explain analyze"
],
"children"
:
[],
"export"
:
[],
"export"
:
[
"explain.json"
],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
"group"
:
2
}
\ No newline at end of file
data/3.MySQL高阶/7.查询优化/3. EXPLAIN/explain.json
0 → 100644
浏览文件 @
ea9b0488
{
"type"
:
"code_options"
,
"author"
:
"ccat"
,
"source"
:
"explain.md"
,
"notebook_enable"
:
false
,
"exercise_id"
:
"590a05e39b854e83b081d1984aef191a"
}
\ No newline at end of file
data/3.MySQL高阶/7.查询优化/3. EXPLAIN/explain.md
0 → 100644
浏览文件 @
ea9b0488
# EXPLAIN
Joe 从交易服务中发现了一些高频查询和慢查询,例如
```
mysql
with recursive r(id) as (select id
from orders
where id = $1
union
select d.id
from orders as d
join r on d.id = r.id + 1)
select orders.id, content
from orders
join r on orders.id = r.id;
```
,他应该从何入手分析优化?
## 答案
在测试库使用
```
mysql
explain with recursive r(id) as (select id
from orders
where id = $1
union
select d.id
from orders as d
join r on d.id = r.id + 1)
select orders.id, content
from orders
join r on orders.id = r.id;
```
进行剖分,对于需要了解详细执行计划的使用
```
mysql
explain analyze with recursive r(id) as (select id
from orders
where id = 100
union
select d.id
from orders as d
join r on d.id = r.id + 1)
select orders.id
from orders
join r on orders.id = r.id;
```
进行详细分析。
## 选项
### A
对查询设计的字段加索引
### B
备份数据库,删除重建
### C
使用
```
mysql
analyze with recursive r(id) as (select id
from orders
where id = 100
union
select d.id
from orders as d
join r on d.id = r.id + 1)
select orders.id
from orders
join r on orders.id = r.id;
```
进行剖分。
\ No newline at end of file
data/tree.json
浏览文件 @
ea9b0488
...
...
@@ -2048,31 +2048,32 @@
"children"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
"group"
:
2
}
},
{
"
EXPLAIN
"
:
{
"node_id"
:
"mysql-
a42f617d4eb54aabbc649bdde4485117
"
,
"
SHOW PROFILE
"
:
{
"node_id"
:
"mysql-
f0b12126dd3e4be09010a308a822bc32
"
,
"keywords"
:
[
"
explain
"
"
show profile
"
],
"children"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
"group"
:
2
}
},
{
"
SHOW PROFILE
"
:
{
"node_id"
:
"mysql-
f0b12126dd3e4be09010a308a822bc32
"
,
"
EXPLAIN
"
:
{
"node_id"
:
"mysql-
a42f617d4eb54aabbc649bdde4485117
"
,
"keywords"
:
[
"show profile"
"explain"
,
"explain analyze"
],
"children"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
"group"
:
2
}
}
],
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录