InnoDB PRIMARY KEY Design

Source: Internet
Author: User

InnoDB is Clustered-index table, so for InnoDB, the primary key has a special meaning. You can navigate directly to the physical location of the corresponding data row record by the primary key, the primary key index points to the corresponding row record, and the other indexes to the primary key index; So, so to speak, InnoDB is actually a B-tree index, the B-Tree index is the primary key, and its value is the corresponding row record.
In the InnoDB data sheet design, we need to pay attention to several points:

    • 1. Explicitly define a primary key for an INT type self-increment field that can be used only for the master key and not for other purposes
    • 2. If you do not explicitly define a primary key, you may cause InnoDB to sort new rows of data each time, severely compromising performance
    • 3. Try to ensure that the primary key field is not updated to prevent changes in the primary key fields, causing data storage fragmentation and reducing IO performance
    • 4. If you need to update the primary key field, turn the field into a unique index constraint field and create a self-increment field with no other business meaning.
    • 5. Primary key field type as small as possible, can use smallint without int, can use int without bigint
    • 6. Primary key fields are placed in the first order of the data table

InnoDB PRIMARY KEY Design

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.