Several graphs describe the data distribution of MyISAM and InnoDB and the data distribution differences between primary key indexes and level two indexes

Source: Internet
Author: User

Table structure:

CREATE TABLE Layout_test (

col1 int not NULL,

col2 int not NULL,

PRIMARY KEY (col1),

KEY (col2)

);

Description: The table's primary key value (col1) is 1~100000, but is inserted in random order

The values of column col2 are randomly assigned between 1~100, so there are many duplicate values.



MyISAM table (non-clustered index):

Data Distribution Chart:

Primary key Data distribution:


Col2 column index distribution (in fact, no difference from primary key index distribution)




InnoDB Data distribution (supports clustered index, index is table, so data does not need isolated storage like MyISAM)

Primary Key distribution (using a clustered index, each leaf node contains a primary key value, a transaction ID, a rollback pointer for transactions and MVCC, and all remaining columns)



Secondary index (Index on col2 column, and clustered index very different, the leaf node of level Two index contains index column and primary key column, store not "row child pin", but primary key value)




Final comparison Chart


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.