MySQL InnoDB Row Formats

Intro

  1. Row Format Impact: The row format determines how table rows are physically stored, which can affect query performance and DML (Data Manipulation Language) operations. More rows fitting into a single disk page can lead to faster queries and index lookups, reduced cache memory requirements, and less I/O for updating values.

  2. Data Storage: Data in each table is divided into pages, and these pages are arranged in a B-tree index, which is used for both table data and secondary indexes. The primary key columns organize the clustered index, which is a type of B-tree index representing an entire table.

  3. Variable-Length Columns: These columns, if too long to fit on a B-tree page, are stored on separate disk pages known as overflow pages. These are referred to as off-page columns and are linked in a singly-linked list.

  4. Row Formats: InnoDB supports four row formats:

    • REDUNDANT: Offers compatibility with older MySQL versions and stores the first 768 bytes of variable-length columns in the index record.
    • COMPACT: Reduces row storage space by about 20% compared to REDUNDANT but may increase CPU usage.
    • DYNAMIC: Similar to COMPACT but offers enhanced storage for long variable-length columns and supports large index key prefixes up to 3072 bytes.
    • COMPRESSED: Like DYNAMIC, but adds support for table and index data compression. It uses smaller page sizes and is only supported in file-per-table or general tablespaces.
  5. Defining Row Format: The default row format for InnoDB tables is defined by the innodb_default_row_format system variable, which defaults to DYNAMIC. The row format for a table can be explicitly set using the ROW_FORMAT option in CREATE TABLE or ALTER TABLE statements.

  6. Determining Row Format: The row format of a table can be determined using the SHOW TABLE STATUS command or by querying the INFORMATION_SCHEMA.INNODB_TABLES table.

  7. Storage Characteristics: Each row format has specific storage characteristics that define how data is organized and stored within the index records, including the handling of NULL values, variable-length columns, and fixed-length columns.

  8. Table Rebuilding Operations: Operations that rebuild a table, such as certain ALTER TABLE commands or OPTIMIZE TABLE, may change the row format to the default if one is not explicitly defined.

  9. Replication and Schema Mismatch: When changing row formats, especially in replication environments, it's important to consider compatibility issues that may arise due to differences in supported index key prefix lengths or default row format settings between the source and replica systems.

See

MySQL :: MySQL 8.0 Reference Manual :: 17.10 InnoDB Row Formats

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

P("Struggler") ?

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值