[MySQL 面试题]-内部技术架构 53-54 多个索引的选择发生在哪个阶段?

38 阅读1分钟

image.png

53 多个索引的选择发生在哪个阶段?

客户端 → 连接器 → 分析器 Parser → 优化器 Optimizer ✅ → 执行器 Executor
多个索引选择在哪个阶段?✅ 在优化器(Optimizer)阶段完成
优化器怎么决定选哪个索引?根据统计信息、过滤效率、排序、是否覆盖索引、执行成本等因素分析
能否查看选择过程?✅ 可以,通过 EXPLAIN / optimizer_trace 查看

54 MySQL 支持哪些存储引擎?默认使用哪个?

mysql> show engines;
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine             | Support | Comment                                                        | Transactions | XA   | Savepoints |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| ndbcluster         | NO      | Clustered, fault-tolerant(容错) tables                               | NULL         | NULL | NULL       |
| CSV                | YES     | CSV storage engine                                             | NO           | NO   | NO         |
| ARCHIVE            | YES     | Archive storage engine                                         | NO           | NO   | NO         |
| BLACKHOLE          | YES     | /dev/null storage engine (anything you write to it disappears) | NO           | NO   | NO         |
| ndbinfo            | NO      | MySQL Cluster system information storage engine                | NULL         | NULL | NULL       |
| MRG_MYISAM         | YES     | Collection of identical MyISAM tables                          | NO           | NO   | NO         |
| FEDERATED          | NO      | Federated MySQL storage engine                                 | NULL         | NULL | NULL       |
| MyISAM             | YES     | MyISAM storage engine                                          | NO           | NO   | NO         |
| PERFORMANCE_SCHEMA | YES     | Performance Schema                                             | NO           | NO   | NO         |
| InnoDB             | DEFAULT | Supports transactions, row-level locking, and foreign keys     | YES          | YES  | YES        |
| MEMORY             | YES     | Hash based, stored in memory, useful for temporary tables      | NO           | NO   | NO         |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
mysql> SHOW VARIABLES LIKE '%default_storage_engine%';
+------------------------+--------+
| Variable_name          | Value  |
+------------------------+--------+
| default_storage_engine | InnoDB |
+------------------------+--------+

Blackhole(黑洞)存储引擎

“写得进去,查不出来” —— 所有写入(INSERT)会被接受,但不进行物理存储,查询(SELECT)永远返回空集.

主从复制过滤器/中继主库写入数据,Blackhole 不存数据但生成 binlog,供从库同步