Giter VIP home page Giter VIP logo

Comments (1)

Snailclimb avatar Snailclimb commented on May 28, 2024

mysql索引详解一文中提及聚簇索引和非聚簇索引的定义:

  • 聚簇索引(Clustered Index)即索引结构和数据一起存放的索引,并不是一种单独的索引类型。InnoDB 中的主键索引就属于聚簇索引。
  • 非聚簇索引(Non-Clustered Index)即索引结构和数据分开存放的索引,并不是一种单独的索引类型。二级索引(辅助索引)就属于非聚簇索引。MySQL 的 MyISAM 引擎,不管主键还是非主键,使用的都是非聚簇索引。

若只针对mysql而言是合理的,但此处应该是不考虑具体数据库,更宽泛的关于聚簇索引和非聚簇索引的定义。聚簇索引应为索引中数据项(data entry)的顺序与实际磁盘中数据(data record)存放的顺序相同(或相近)的索引,非聚簇索引反之。也就是说索引中数据页并不一定要存放完整的数据(data record),可以是真实数据地址。恰好mysql会创建一个包含完整数据的主键索引,所以唯一的聚簇索引就是和数据一起存放的索引。但实质上聚簇索引的定义与所谓索引结构和数据是否一起存放无关。我翻看了两本比较权威的数据库教材:

If the file containing the records is sequentially ordered, a clustering index is an index whose search key also defines the sequential order of the file. Clustering indices are also called primary indices; the term primary index may appear to denote an index on a primary key, but such indices can in fact be built on any search key. The search key of a clustering index is often the primary key, although that is not necessarily so. Indices whose search key specifies an order different from the sequential order of the file are called nonclustering indices, or secondary indices. The terms “clustered” and “nonclustered” are often used in place of “clustering” and “nonclustering.” - Database System Concepts (SILBERSCHATZ)

When a file is organized so that the ordering of data records is the same as or close to the ordering of data entries in some index, we say that the index is clustered; otherwise, it clustered is an unclustered index. - Database Management Systems (Ramakrishnan)

嗯嗯,这里确实主要针对的是 MySQL 数据库。你可以提交一个PR补充完善一下。

from javaguide.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.