新文章

This commit is contained in:
2025-09-08 13:55:44 +00:00
parent 9221b39213
commit 43c1762441
9 changed files with 77 additions and 14 deletions

0
public/api/i/2025/09/07/xy0628-1.webp Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

0
public/api/i/2025/09/07/xz52lm-1.webp Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

0
public/api/i/2025/09/07/yscnoh-1.webp Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

0
public/api/i/2025/09/07/yu38tz-1.webp Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

View File

@@ -0,0 +1,22 @@
---
title: MySQL中几种count的区别
published: 2025-09-07
description: "MySQL中count(*),count(1)和count(字段名)的区别"
image: ""
tags: ["count", "MySQL"]
category: "中间件 > MySQL"
draft: false
lang: ""
---
# count(\*) 和 count(1)
是用来统计行数的聚合函数,统计表中的全部行的数量,包括 null 值
# count(字段名)
也是用来统计行数的聚合函数,会统计指定字段下不为 null 的行数,这种写法会对指定的字段进行计数,只会统计字段值不为 null 的行。
![](https://blog.meowrain.cn/api/i/2025/09/07/zckucc-1.webp)
![](https://blog.meowrain.cn/api/i/2025/09/07/zebv8e-1.webp)

View File

@@ -0,0 +1,10 @@
---
title: MySQL中的数据排序是怎么实现的
published: 2025-09-07
description: ''
image: ''
tags: []
category: ''
draft: false
lang: ''
---

View File

@@ -1,32 +1,38 @@
---
title: MySQL索引类型有哪些
published: 2025-08-14
description: ''
image: ''
description: ""
image: ""
tags: [索引, MySQL]
category: '中间件 > MySQL'
category: "中间件 > MySQL"
draft: false
lang: ''
lang: ""
---
# MySQL索引类型有哪些
# MySQL 索引类型有哪些
## 按数据结构分
分为
- B-Tree索引
- Hash索引
- Full-text索引
- B-Tree 索引
- Hash 索引
- Full-text 索引
![](https://blog.meowrain.cn/api/i/2025/08/15/5dxy1-1.webp)
创建表的时候InnoDB存储引擎会根据不同的场景选择不同的列作为索引
创建表的时候InnoDB 存储引擎会根据不同的场景选择不同的列作为索引:
- 有主键:会使用主键作为聚簇索引的索引键
- 没有主键: 选择第一个不包含NULL值的唯一列作为聚簇索引的索引键
- 上面两个都没有的情况下InnoDB会自动生成一个隐式自增id列作为聚簇索引的索引键。
- 没有主键: 选择第一个不包含 NULL 值的唯一列作为聚簇索引的索引键
- 上面两个都没有的情况下InnoDB 会自动生成一个隐式自增 id 列作为聚簇索引的索引键。
其他索引都属于辅助索引,也就是非聚簇索引或者二级索引。
## 按物理存储分
分为
- 聚簇索引(主键索引)
- 二级索引(辅助索引)
@@ -37,8 +43,33 @@ lang: ''
- 普通索引
- 前缀索引
主键索引是唯一的且不允许为NULL。每个表只能有一个主键索引。
主键索引是唯一的,且不允许为 NULL。每个表只能有一个主键索引。
## 按字段个数分
- 单列索引
- 联合索引
---
# 按数据结构分
- B+树索引
- 哈希索引
- 倒排索引Full-text 索引)
- R-树索引 (多维树空间)
从 InnoDB b+树索引来看,分为聚簇索引和非聚簇索引
聚簇索引也就是主键索引,叶子节点存储整行的数据,非叶子节点存储主键值和指向子节点的指针。
非聚簇索引叶子节点存储主键,非叶子节点存储主键值和指向子节点的指针。
因此,非聚簇索引查询需要回表查询
# 从索引性质看
普通索引
主键索引
唯一索引
联合索引
全文索引
空间索引