Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CSDN 技术社区
skill_tree_mysql
提交
93e78662
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看板
提交
93e78662
编写于
6月 07, 2022
作者:
M
Mars Liu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
index
上级
9d06ce74
变更
26
显示空白变更内容
内联
并排
Showing
26 changed file
with
256 addition
and
63 deletion
+256
-63
data/2.MySQL中阶/3.聚合和分组/2. 求和/sum.json
data/2.MySQL中阶/3.聚合和分组/2. 求和/sum.json
+3
-2
data/3.MySQL高阶/1.深入索引/10.函数索引/config.json
data/3.MySQL高阶/1.深入索引/10.函数索引/config.json
+0
-0
data/3.MySQL高阶/1.深入索引/2.唯一索引/config.json
data/3.MySQL高阶/1.深入索引/2.唯一索引/config.json
+8
-3
data/3.MySQL高阶/1.深入索引/2.唯一索引/unique.json
data/3.MySQL高阶/1.深入索引/2.唯一索引/unique.json
+8
-0
data/3.MySQL高阶/1.深入索引/2.唯一索引/unique.md
data/3.MySQL高阶/1.深入索引/2.唯一索引/unique.md
+42
-0
data/3.MySQL高阶/1.深入索引/3.全值匹配/config.json
data/3.MySQL高阶/1.深入索引/3.全值匹配/config.json
+12
-4
data/3.MySQL高阶/1.深入索引/3.全值匹配/total_index.json
data/3.MySQL高阶/1.深入索引/3.全值匹配/total_index.json
+8
-0
data/3.MySQL高阶/1.深入索引/3.全值匹配/total_index.md
data/3.MySQL高阶/1.深入索引/3.全值匹配/total_index.md
+43
-0
data/3.MySQL高阶/1.深入索引/5.匹配顺序/config.json
data/3.MySQL高阶/1.深入索引/5.匹配顺序/config.json
+3
-1
data/3.MySQL高阶/1.深入索引/5.匹配顺序/match_fields.json
data/3.MySQL高阶/1.深入索引/5.匹配顺序/match_fields.json
+8
-0
data/3.MySQL高阶/1.深入索引/5.匹配顺序/match_fields.md
data/3.MySQL高阶/1.深入索引/5.匹配顺序/match_fields.md
+53
-0
data/3.MySQL高阶/1.深入索引/6.精确匹配与范围匹配/config.json
data/3.MySQL高阶/1.深入索引/6.精确匹配与范围匹配/config.json
+0
-10
data/3.MySQL高阶/1.深入索引/6.组合索引/combinate.json
data/3.MySQL高阶/1.深入索引/6.组合索引/combinate.json
+8
-0
data/3.MySQL高阶/1.深入索引/6.组合索引/combinate.md
data/3.MySQL高阶/1.深入索引/6.组合索引/combinate.md
+44
-0
data/3.MySQL高阶/1.深入索引/6.组合索引/config.json
data/3.MySQL高阶/1.深入索引/6.组合索引/config.json
+8
-3
data/3.MySQL高阶/1.深入索引/7.空间索引/config.json
data/3.MySQL高阶/1.深入索引/7.空间索引/config.json
+0
-0
data/3.MySQL高阶/1.深入索引/7.空间索引/geo_index.json
data/3.MySQL高阶/1.深入索引/7.空间索引/geo_index.json
+0
-0
data/3.MySQL高阶/1.深入索引/7.空间索引/geo_index.md
data/3.MySQL高阶/1.深入索引/7.空间索引/geo_index.md
+0
-0
data/3.MySQL高阶/1.深入索引/7.连接查询与索引/config.json
data/3.MySQL高阶/1.深入索引/7.连接查询与索引/config.json
+0
-10
data/3.MySQL高阶/1.深入索引/8.全文索引/config.json
data/3.MySQL高阶/1.深入索引/8.全文索引/config.json
+2
-1
data/3.MySQL高阶/1.深入索引/8.全文索引/full_text_index.json
data/3.MySQL高阶/1.深入索引/8.全文索引/full_text_index.json
+0
-0
data/3.MySQL高阶/1.深入索引/8.全文索引/full_text_index.md
data/3.MySQL高阶/1.深入索引/8.全文索引/full_text_index.md
+0
-0
data/3.MySQL高阶/1.深入索引/9.隐藏索引/config.json
data/3.MySQL高阶/1.深入索引/9.隐藏索引/config.json
+1
-1
data/3.MySQL高阶/1.深入索引/9.隐藏索引/invisible.json
data/3.MySQL高阶/1.深入索引/9.隐藏索引/invisible.json
+0
-0
data/3.MySQL高阶/1.深入索引/9.隐藏索引/invisible.md
data/3.MySQL高阶/1.深入索引/9.隐藏索引/invisible.md
+0
-0
data/tree.json
data/tree.json
+5
-28
未找到文件。
data/2.MySQL中阶/3.聚合和分组/2. 求和/sum.json
浏览文件 @
93e78662
{
"type"
:
"code_options"
,
"author"
:
"
ccat
"
,
"author"
:
"
Mars
"
,
"source"
:
"sum.md"
,
"notebook_enable"
:
false
,
"exercise_id"
:
"
6ac9bb99a6684023ad80fde36ea32f6a
"
"exercise_id"
:
"
1beebe6f7dcb4c8db11cc6d5151c395d
"
}
\ No newline at end of file
data/3.MySQL高阶/1.深入索引/1
2
.函数索引/config.json
→
data/3.MySQL高阶/1.深入索引/1
0
.函数索引/config.json
浏览文件 @
93e78662
文件已移动
data/3.MySQL高阶/1.深入索引/2.唯一索引/config.json
浏览文件 @
93e78662
{
"node_id"
:
"mysql-db7153c698e8442eb5f71e8ec2f2e6cd"
,
"keywords"
:
[
"unique"
],
"keywords"
:
[
"unique"
],
"children"
:
[],
"export"
:
[],
"export"
:
[
"unique.json"
],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
"group"
:
1
}
\ No newline at end of file
data/3.MySQL高阶/1.深入索引/2.唯一索引/unique.json
0 → 100644
浏览文件 @
93e78662
{
"type"
:
"code_options"
,
"author"
:
"ccat"
,
"source"
:
"unique.md"
,
"notebook_enable"
:
false
,
"exercise_id"
:
"959101e435844130811d359d7abcab04"
}
\ No newline at end of file
data/3.MySQL高阶/1.深入索引/2.唯一索引/unique.md
0 → 100644
浏览文件 @
93e78662
# 唯一约束
Goods 表结构如下:
```
mysql
create table goods(
id int primary key auto_increment,
category_id int,
name varchar(256),
price decimal(12, 4),
stock int,
upper_time timestamp
)
```
Joe 需要确保同一个类型下没有重名的商品,他应该怎么做?
## 答案
```
mysql
alter table goods add unique index (category_id, name);
```
## 选项
### A
```
mysql
alter table goods add index (category_id, name);
```
### B
```
mysql
alter table goods add unique index (category_id + name);
```
### C
```
mysql
alter table goods add unique index (concat(category_id, name));
```
data/3.MySQL高阶/1.深入索引/3.全值匹配/config.json
浏览文件 @
93e78662
{
"node_id"
:
"mysql-391b51e398764531abf5a6e036699cc8"
,
"keywords"
:
[
"equals"
,
"not equals"
,
"相等"
,
"不等"
,
"全值"
],
"keywords"
:
[
"equals"
,
"not equals"
,
"相等"
,
"不等"
,
"全值"
],
"children"
:
[],
"export"
:
[],
"export"
:
[
"total_index.json"
],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
"group"
:
2
}
\ No newline at end of file
data/3.MySQL高阶/1.深入索引/3.全值匹配/total_index.json
0 → 100644
浏览文件 @
93e78662
{
"type"
:
"code_options"
,
"author"
:
"ccat"
,
"source"
:
"limit_action.md"
,
"notebook_enable"
:
false
,
"exercise_id"
:
"2c68494e5e9f4f9b835bd5758d61f6b9"
}
\ No newline at end of file
data/3.MySQL高阶/1.深入索引/3.全值匹配/total_index.md
0 → 100644
浏览文件 @
93e78662
# 全值匹配
Goods 表结构如下:
```
mysql
create table goods(
id int primary key auto_increment,
category_id int,
name varchar(256),
price decimal(12, 4),
stock int,
upper_time timestamp
)
```
现在有大量根据商品名获取价格的查询
`select price from goods where name = '...''`
,Joe希望进行优化,那么他应该:
## 答案
```
mysql
alter table goods add index (name, price);
```
## 选项
### A
将 name 和 price 合成一个字段。
### B
建立一个计算字段:
```
mysql
alter table goods add summary varchar(1024) generated always as (concat(name, '(', 0.5, ')'));
```
### C
```
mysql
alter table goods add index (concat(name, price));
```
\ No newline at end of file
data/3.MySQL高阶/1.深入索引/5.
前缀匹配
/config.json
→
data/3.MySQL高阶/1.深入索引/5.
匹配顺序
/config.json
浏览文件 @
93e78662
...
...
@@ -2,7 +2,9 @@
"node_id"
:
"mysql-bdc593e4b7ea4c8aa248227ff2e1221d"
,
"keywords"
:
[],
"children"
:
[],
"export"
:
[],
"export"
:
[
"match_fields.json"
],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
...
...
data/3.MySQL高阶/1.深入索引/5.匹配顺序/match_fields.json
0 → 100644
浏览文件 @
93e78662
{
"type"
:
"code_options"
,
"author"
:
"ccat"
,
"source"
:
"match_fields.md"
,
"notebook_enable"
:
false
,
"exercise_id"
:
"7d5c09ded4ff44dda7928f0d902a9afe"
}
\ No newline at end of file
data/3.MySQL高阶/1.深入索引/5.匹配顺序/match_fields.md
0 → 100644
浏览文件 @
93e78662
# 左匹配
Goods 表结构如下:
```
mysql
create table goods(
id int primary key auto_increment,
category_id int,
name varchar(256),
price decimal(12, 4),
stock int,
upper_time timestamp,
index (category_id, name)
)
```
Joe 发现有大量查询
`select id, category_id, name, price from goods where name=? and category_id=?`
,
性能很差,应该如何优化?
## 答案
将该查询改写为
```
mysql
select id, category_id, name, price from goods where category_id=? and name=?;
```
## 选项
### A
将该查询改写为
```
mysql
select id, category_id, name, price from goods where category_id and name= (?, ?);
```
### B
将该查询改写为
```
mysql
select id, category_id, name, price from goods where not (category_id !=? or name != ?);
```
### C
将该查询改写为
```
mysql
select id, category_id, name, price from goods where not (category_id !=?) and not (name != ?);
```
data/3.MySQL高阶/1.深入索引/6.精确匹配与范围匹配/config.json
已删除
100644 → 0
浏览文件 @
9d06ce74
{
"node_id"
:
"mysql-2b57deb6baa445ca87e66143624164bb"
,
"keywords"
:
[
"match"
,
"range"
],
"children"
:
[],
"export"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
}
\ No newline at end of file
data/3.MySQL高阶/1.深入索引/6.组合索引/combinate.json
0 → 100644
浏览文件 @
93e78662
{
"type"
:
"code_options"
,
"author"
:
"ccat"
,
"source"
:
"combinate.md"
,
"notebook_enable"
:
false
,
"exercise_id"
:
"163ad81217b246b5a3e8819ecffa8411"
}
\ No newline at end of file
data/3.MySQL高阶/1.深入索引/6.组合索引/combinate.md
0 → 100644
浏览文件 @
93e78662
# 组合索引
Goods 表结构如下:
```
mysql
create table goods(
id int primary key auto_increment,
category_id int,
category varchar(64),
name varchar(256),
price decimal(12, 4),
stock int,
upper_time timestamp
)
```
现有大量查询
`select id, category_id, name, price, stock from goods where stock=? and category_id=? and name like ?`
,
Joe 应该如何优化?
## 答案
```
mysql
alter table goods add index (stock, category_id, name);
```
## 选项
### A
```
mysql
alter table goods add index (stock and category_id and name);
```
### B
```
mysql
alter table goods add index (concat(stock, category_id, name));
```
### C
```
mysql
alter table goods add index (stock + category_id + name);
```
data/3.MySQL高阶/1.深入索引/
8
.组合索引/config.json
→
data/3.MySQL高阶/1.深入索引/
6
.组合索引/config.json
浏览文件 @
93e78662
{
"node_id"
:
"mysql-ce1f863b4d254d2aadb6ce2331122d16"
,
"keywords"
:
[
"compose"
],
"keywords"
:
[
"compose"
],
"children"
:
[],
"export"
:
[],
"export"
:
[
"combinate.json"
],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
"group"
:
1
}
\ No newline at end of file
data/3.MySQL高阶/1.深入索引/
9
.空间索引/config.json
→
data/3.MySQL高阶/1.深入索引/
7
.空间索引/config.json
浏览文件 @
93e78662
文件已移动
data/3.MySQL高阶/1.深入索引/
9
.空间索引/geo_index.json
→
data/3.MySQL高阶/1.深入索引/
7
.空间索引/geo_index.json
浏览文件 @
93e78662
文件已移动
data/3.MySQL高阶/1.深入索引/
9
.空间索引/geo_index.md
→
data/3.MySQL高阶/1.深入索引/
7
.空间索引/geo_index.md
浏览文件 @
93e78662
文件已移动
data/3.MySQL高阶/1.深入索引/7.连接查询与索引/config.json
已删除
100644 → 0
浏览文件 @
9d06ce74
{
"node_id"
:
"mysql-8e4a5a0e19e04932b9680ea24364fdd4"
,
"keywords"
:
[],
"children"
:
[],
"export"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
}
\ No newline at end of file
data/3.MySQL高阶/1.深入索引/
10
.全文索引/config.json
→
data/3.MySQL高阶/1.深入索引/
8
.全文索引/config.json
浏览文件 @
93e78662
...
...
@@ -10,5 +10,5 @@
],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
"group"
:
2
}
\ No newline at end of file
data/3.MySQL高阶/1.深入索引/
10
.全文索引/full_text_index.json
→
data/3.MySQL高阶/1.深入索引/
8
.全文索引/full_text_index.json
浏览文件 @
93e78662
文件已移动
data/3.MySQL高阶/1.深入索引/
10
.全文索引/full_text_index.md
→
data/3.MySQL高阶/1.深入索引/
8
.全文索引/full_text_index.md
浏览文件 @
93e78662
文件已移动
data/3.MySQL高阶/1.深入索引/
11
.隐藏索引/config.json
→
data/3.MySQL高阶/1.深入索引/
9
.隐藏索引/config.json
浏览文件 @
93e78662
{
"node_id"
:
"mysql-c57e1195b0914cd38798ce029156ec87"
,
"keywords"
:
[],
"keywords"
:
[
"invisible"
,
"visible"
,
"隐藏索引"
],
"children"
:
[],
"export"
:
[
"invisible.json"
...
...
data/3.MySQL高阶/1.深入索引/
11
.隐藏索引/invisible.json
→
data/3.MySQL高阶/1.深入索引/
9
.隐藏索引/invisible.json
浏览文件 @
93e78662
文件已移动
data/3.MySQL高阶/1.深入索引/
11
.隐藏索引/invisible.md
→
data/3.MySQL高阶/1.深入索引/
9
.隐藏索引/invisible.md
浏览文件 @
93e78662
文件已移动
data/tree.json
浏览文件 @
93e78662
...
...
@@ -1460,7 +1460,7 @@
"children"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
"group"
:
1
}
},
{
...
...
@@ -1476,7 +1476,7 @@
"children"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
"group"
:
2
}
},
{
...
...
@@ -1490,7 +1490,7 @@
}
},
{
"
前缀匹配
"
:
{
"
匹配顺序
"
:
{
"node_id"
:
"mysql-bdc593e4b7ea4c8aa248227ff2e1221d"
,
"keywords"
:
[],
"children"
:
[],
...
...
@@ -1499,29 +1499,6 @@
"group"
:
0
}
},
{
"精确匹配与范围匹配"
:
{
"node_id"
:
"mysql-2b57deb6baa445ca87e66143624164bb"
,
"keywords"
:
[
"match"
,
"range"
],
"children"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
}
},
{
"连接查询与索引"
:
{
"node_id"
:
"mysql-8e4a5a0e19e04932b9680ea24364fdd4"
,
"keywords"
:
[],
"children"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
}
},
{
"组合索引"
:
{
"node_id"
:
"mysql-ce1f863b4d254d2aadb6ce2331122d16"
,
...
...
@@ -1531,7 +1508,7 @@
"children"
:
[],
"keywords_must"
:
[],
"keywords_forbid"
:
[],
"group"
:
0
"group"
:
1
}
},
{
...
...
@@ -1554,7 +1531,7 @@
"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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录