1. <small id='tvWF4'></small><noframes id='tvWF4'>

      • <bdo id='tvWF4'></bdo><ul id='tvWF4'></ul>
      1. <legend id='tvWF4'><style id='tvWF4'><dir id='tvWF4'><q id='tvWF4'></q></dir></style></legend>
      2. <i id='tvWF4'><tr id='tvWF4'><dt id='tvWF4'><q id='tvWF4'><span id='tvWF4'><b id='tvWF4'><form id='tvWF4'><ins id='tvWF4'></ins><ul id='tvWF4'></ul><sub id='tvWF4'></sub></form><legend id='tvWF4'></legend><bdo id='tvWF4'><pre id='tvWF4'><center id='tvWF4'></center></pre></bdo></b><th id='tvWF4'></th></span></q></dt></tr></i><div id='tvWF4'><tfoot id='tvWF4'></tfoot><dl id='tvWF4'><fieldset id='tvWF4'></fieldset></dl></div>
      3. <tfoot id='tvWF4'></tfoot>

        B 树索引如何在 mysql 中工作

        时间:2023-10-26
          <bdo id='lRDkX'></bdo><ul id='lRDkX'></ul>

          1. <legend id='lRDkX'><style id='lRDkX'><dir id='lRDkX'><q id='lRDkX'></q></dir></style></legend>
              • <tfoot id='lRDkX'></tfoot>
                  <tbody id='lRDkX'></tbody>

                <small id='lRDkX'></small><noframes id='lRDkX'>

                • <i id='lRDkX'><tr id='lRDkX'><dt id='lRDkX'><q id='lRDkX'><span id='lRDkX'><b id='lRDkX'><form id='lRDkX'><ins id='lRDkX'></ins><ul id='lRDkX'></ul><sub id='lRDkX'></sub></form><legend id='lRDkX'></legend><bdo id='lRDkX'><pre id='lRDkX'><center id='lRDkX'></center></pre></bdo></b><th id='lRDkX'></th></span></q></dt></tr></i><div id='lRDkX'><tfoot id='lRDkX'></tfoot><dl id='lRDkX'><fieldset id='lRDkX'></fieldset></dl></div>
                  本文介绍了B 树索引如何在 mysql 中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  当我为 mysql 中的表创建索引时,我看到 index_type 是 BTREE 类型.现在虽然我了解 btree(s),但我不太明白它如何存储索引以及数据库如何基于此搜索记录.

                  When I create an index for a table in mysql, I see that the index_type is type BTREE. Now although I understand about btree(s), I do not quiet understand how it stores the index and how the database searches the records based on this.

                  我的意思是,btree 非常适合数据库执行读取和写入大数据块,当我们为 Primary key 的列类型创建索引时,我的理解是,它创建了一棵树并根据根的值类型拆分根的值.

                  I mean, btree is excellent for databases to perform read and writes large blocks of data, when we create an index for column type of Primary key, what I understand is, it creates a tree and splitting the values for the root based on the value type of the root.

                  现在,它是只存储树下的主键 ID 还是与该主键关联的整个数据?

                  Now, does it store only the the primary key ID under the trees or the whole data associated with that primary key?

                  找到想要的主ID后,数据库如何提取记录?

                  After finding the wanted primary ID, how does the database extract the record?

                  推荐答案

                  数据库将索引值存储为 B-Tree 键,记录指针存储为 B-Tree 值.

                  The database stores the value indexed as a B-Tree key, and the record pointer as a B-Tree value.

                  每当您搜索包含某个索引列的某个值的记录时,引擎都会在 B-Tree 中定位包含该值的键,检索指向该记录的指针并获取该记录.

                  Whenever you search for a record holding a certain value of an indexed column, the engine locates the key holding this value in the B-Tree, retrieves the pointer to the record and fetches the record.

                  究竟什么是记录指针",取决于存储引擎.

                  What exactly is a "record pointer", depends on the storage engine.

                  • MyISAM中,记录指针是MYI文件中记录的偏移量.

                  • In MyISAM, the record pointer is an offset to the record in the MYI file.

                  InnoDB中,记录指针是PRIMARY KEY的值.

                  In InnoDB, the record pointer is the value of the PRIMARY KEY.

                  InnoDB中,表本身是一个B-Tree,带有一个PRIMARY KEY作为B-Tree> 键.这就是所谓的聚集索引"或索引组织表".在这种情况下,所有其他字段都存储为 B-Tree 值.

                  In InnoDB, the table itself is a B-Tree with a PRIMARY KEY as a B-Tree key. This is what called a "clustered index" or "index-organized table". In this case, all other fields are stored as a B-Tree value.

                  MyISAM中,记录的存储没有任何特殊的顺序.这称为堆存储".

                  In MyISAM, the records are stored without any special order. This is called "heap storage".

                  这篇关于B 树索引如何在 mysql 中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 MySQL 表中搜索包含 CSV 数据的列是否存在输入值 下一篇:Mysql 使用 MATCH() AGAINST() 搜索字符串和数字

                  相关文章

                    <bdo id='gz2A2'></bdo><ul id='gz2A2'></ul>

                  <small id='gz2A2'></small><noframes id='gz2A2'>

                    <legend id='gz2A2'><style id='gz2A2'><dir id='gz2A2'><q id='gz2A2'></q></dir></style></legend><tfoot id='gz2A2'></tfoot>

                  1. <i id='gz2A2'><tr id='gz2A2'><dt id='gz2A2'><q id='gz2A2'><span id='gz2A2'><b id='gz2A2'><form id='gz2A2'><ins id='gz2A2'></ins><ul id='gz2A2'></ul><sub id='gz2A2'></sub></form><legend id='gz2A2'></legend><bdo id='gz2A2'><pre id='gz2A2'><center id='gz2A2'></center></pre></bdo></b><th id='gz2A2'></th></span></q></dt></tr></i><div id='gz2A2'><tfoot id='gz2A2'></tfoot><dl id='gz2A2'><fieldset id='gz2A2'></fieldset></dl></div>