当前位置:网站首页>B+ tree (5) introduction to MyISAM -- MySQL from getting started to mastering (17)
B+ tree (5) introduction to MyISAM -- MySQL from getting started to mastering (17)
2022-07-26 13:17:00 【User 9919783】
In the last article, we said , A federated index uses more than two columns to create an index ,b+ The tree is a , First use c2 Column sorting , If the result is the same , Then use c3 Sort .innoDB Of b+ The characteristic of tree is that the root node remains unchanged , The new table has a clustered index by default , First, there is a root node without data , Put the user record data into the root points , When the data is slow , Page splitting , There will be many nodes , At this moment, the root node evolves into a root directory record node , Data is stored in the underlying node . The inner nodes of the secondary index ensure consistency , Add a primary key when saving column values .
B+ Trees (4) Joint index --mysql From entry to mastery ( sixteen )
myISAM brief introduction
We know innoDB The index of search engine is data , It is divided into list value index tree , And clustered index tree , Cluster index that b+ A tree index is data , All user records exist in leaf nodes . and myISAM Although it is also B+ Trees , But indexes and data are separate .
myISAM Yes, the user record data is all put in one file , It's called a data file , This file will not be divided into several pages , Just stuff as many records as you have , Through the corresponding line number of each line, you can quickly access , Because it is inserted at will , It will not be sorted by primary key size , Cannot use binary search method to find .
Then the index information will be stored in another index file ,myISAM The index will be created separately for the primary key of the table , Only the user record data is not stored in the leaf node , It's the primary key + Line number , It means that after finding the corresponding line number , I will use the line number to find all the data in the data file again . therefore myISAM Every query must be returned to the table , Equivalent to secondary index .(innoDB The cluster index of is to find the corresponding inner node directly in the root directory record page according to the primary key , Find all the data on the corresponding underlying leaf node ).
If necessary , You can also create secondary indexes or joint indexes , Only the leaf node stores column values + Line number .
Create index and delete index :
So much theoretical knowledge , How to fight in practice ?mysql Medium innoDB and myISAM The table will automatically be the primary key or declared as unique To create a clustered index , But if you need to create secondary indexes for other columns , You need to in sql Show indication in . Why not create it automatically , Don't forget that more indexes mean more b+ Trees , It means that both insert and delete require huge memory to maintain b+ Trees , It's very performance intensive .
When creating tables, you can create indexes ,index and key Keywords can be used , Appoint indx_tb_col Tabular c2 As a idx_c2 Index of names :
create table index_tb_col(
c1 int,
c2 int,
c3 char(1),
index idx_c2 (c2)
)row_format=Compact;Or after the table is created , Appoint c3 by idx_c3 Index of names :
mysql> alter table index_tb_col add index idx_c3 (c3);
Query OK, 0 rows affected (0.04 sec)You can also add federated indexes and delete indexes :
// Composite index
mysql> create table index_tb_col(
-> c1 int,
-> c2 int,
-> c3 char(1),
-> primary key (c1),
-> index idx_c2_c3 (c2,c3)
-> )row_format=Compact;
Query OK, 0 rows affected (0.03 sec)
// Delete index
mysql> alter table index_tb_col drop index idx_c2_c3;
Query OK, 0 rows affected (0.03 sec)边栏推荐
- Solution: unable to load the file c:\users\user\appdata\roaming\npm\npx PS1, because running scripts is prohibited on this system.
- 子组件触发父组件自定义事件(defineEmits):子组件传值给父组件
- 银行业客户体验管理现状与优化策略分析
- mqtt send receive
- How to remove underline and color when there is focus in the shutter textfield
- V01 - XX, record a good life from the log
- 【TypeScript】TypeScript常用类型(上篇)
- Flink is slow to write redis. Do you have any ideas for optimization?
- Use float to realize left, middle and right layout, and the middle content is adaptive
- Can MySQL customize variable parameter storage functions?
猜你喜欢

Kubelet CRI 容器运行时

Today's sleep quality record 75 points

Kubernetes Flannel:HOST-GW模式

Dimension disaster dimension disaster suspense

高通再次「押宝」中科创达,挑战智能驾驶软硬件全栈方案

同站攻击(相关域攻击)论文阅读 Can I Take Your Subdomain?Exploring Same-Site Attacks in the Modern Web

Shutter background graying effect, how transparency, gray mask

One stroke problem (Chinese postman problem)

银行业客户体验管理现状与优化策略分析

Kubernetes flannel: host-gw mode
随机推荐
二叉树的初阶笔记
基于ASP.NET的某高校学院档案管理系统
[applet] why can't the onreachbottom event be triggered? (one second)
Kubernetes flannel: host-gw mode
V00 - do whatever you want when you are old
jvm:类加载子系统干什么的?由什么组成?需要记住哪些八股文?
LeetCode 263.丑数
0 basic programming resources (collect first ~ read slowly ~)
key&key_len&ref&filtered(4)—mysql执行计划(五十)
Bitwise and how to write SQL
从其他文件触发pytest.main()注意事项
Leetcode 217. there are duplicate elements
Qualcomm once again "bet" on Zhongke Chuangda to challenge the full stack solution of intelligent driving software and hardware
Niuke brush sql---2
目标检测网络R-CNN 系列
概要设计说明书
Today in history: IBM obtained the first patent; Verizon acquires Yahoo; Amazon releases fire phone
panic: Error 1045: Access denied for user ‘root‘@‘117.61.242.215‘ (using password: YES)
Huawei recruited "talented teenagers" twice this year; 5.4 million twitter account information was leaked, with a selling price of $30000; Google fired engineers who believed in AI consciousness | gee
JSON格式执行计划(6)—mysql执行计划(五十二)