MariaDB Enterprise Server InnoDB Dynamic Row Format
This page is part of MariaDB's Documentation.
The parent of this page is: MariaDB Enterprise Server InnoDB Row Formats
Topics on this page:
Overview
The Dynamic row format is the recommended row format. Some details about the Dynamic row format:
The Dynamic row format is the default starting with MariaDB Server 10.2.
The Dynamic row format can most efficiently store large columns that use the CHAR, VARCHAR, LONGTEXT, TEXT, MEDIUMTEXT, and TINYTEXT, VARBINARY, LONGBLOB, BLOB, MEDIUMBLOB, and TINYBLOB data types.
The Dynamic row format can index the longest column values. The limit for indexing column values depends on the innodb_
page_ value.size
Supported Index Prefix Limits
The limit for indexing column values depends on the innodb_
Page Size | Index Prefix Limit |
---|---|
64k 32k 16k | 3072 bytes |
| 1536 bytes |
| 768 bytes |
Create an InnoDB Table with the Dynamic Row Format by Default
InnoDB uses the Dynamic row format for new InnoDB tables by default, because the innodb_dynamic
by default.
Let's create an InnoDB table after confirming that the default storage engine is InnoDB and that InnoDB's default row format is Dynamic:
Connect to the server using MariaDB Client:
$ mariadb --user=root
Confirm that the default storage engine is InnoDB by checking the default_
storage_ system variable using the SHOW SESSION VARIABLES statement:engine SHOW SESSION VARIABLES LIKE 'default_storage_engine';
+------------------------+--------+ | Variable_name | Value | +------------------------+--------+ | default_storage_engine | InnoDB | +------------------------+--------+
Confirm that InnoDB's default row format is Dynamic by checking the innodb_
default_ system variable using the SHOW GLOBAL VARIABLES statement:row_ format SHOW GLOBAL VARIABLES LIKE 'innodb_default_row_format';
+---------------------------+---------+ | Variable_name | Value | +---------------------------+---------+ | innodb_default_row_format | dynamic | +---------------------------+---------+
If the database does not exist, then create the database for the table using the CREATE DATABASE statement:
CREATE DATABASE hq_sales;
Create the table using the CREATE TABLE statement:
CREATE TABLE hq_sales.invoices ( invoice_id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, branch_id INT NOT NULL, customer_id INT, invoice_date DATETIME(6), invoice_total DECIMAL(13, 2), payment_method ENUM('NONE', 'CASH', 'WIRE_TRANSFER', 'CREDIT_CARD', 'GIFT_CARD'), PRIMARY KEY(invoice_id) );
Confirm that the table uses the Dynamic row format by querying the information_
schema.INNODB_ table:SYS_ TABLES SELECT NAME, ROW_FORMAT FROM information_schema.INNODB_SYS_TABLES WHERE NAME='hq_sales/invoices';
+-------------------+------------+ | NAME | ROW_FORMAT | +-------------------+------------+ | hq_sales/invoices | Dynamic | +-------------------+------------+
Create an InnoDB Table with the Dynamic Row Format using ROW_FORMAT
An InnoDB table that uses the Dynamic row format can be created using the the ROW_FORMAT
table option.
Let's create an InnoDB table after confirming that the default storage engine is InnoDB and that InnoDB's default row format is not Dynamic:
Connect to the server using MariaDB Client:
$ mariadb --user=root
Confirm that the default storage engine is InnoDB by checking the default_
storage_ system variable using the SHOW SESSION VARIABLES statement:engine SHOW SESSION VARIABLES LIKE 'default_storage_engine';
+------------------------+--------+ | Variable_name | Value | +------------------------+--------+ | default_storage_engine | InnoDB | +------------------------+--------+
Confirm that InnoDB's default row format is not Dynamic by checking the innodb_
default_ system variable using the SHOW GLOBAL VARIABLES statement:row_ format SHOW GLOBAL VARIABLES LIKE 'innodb_default_row_format';
+---------------------------+---------+ | Variable_name | Value | +---------------------------+---------+ | innodb_default_row_format | compact | +---------------------------+---------+
If the database does not exist, then create the database for the table using the CREATE DATABASE statement:
CREATE DATABASE hq_sales;
Create the table using the CREATE TABLE statement, and specify the Dynamic row format using the
ROW_FORMAT
table option:CREATE TABLE hq_sales.invoices ( invoice_id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, branch_id INT NOT NULL, customer_id INT, invoice_date DATETIME(6), invoice_total DECIMAL(13, 2), payment_method ENUM('NONE', 'CASH', 'WIRE_TRANSFER', 'CREDIT_CARD', 'GIFT_CARD'), PRIMARY KEY(invoice_id) ) ROW_FORMAT = Dynamic;
Confirm that the table uses the Dynamic row format by querying the information_
schema.INNODB_ table:SYS_ TABLES SELECT NAME, ROW_FORMAT FROM information_schema.INNODB_SYS_TABLES WHERE NAME='hq_sales/invoices';
+-------------------+------------+ | NAME | ROW_FORMAT | +-------------------+------------+ | hq_sales/invoices | Dynamic | +-------------------+------------+
Convert InnoDB Tables to the Dynamic Row Format
If your database was physically upgraded from some older version of MariaDB Server or MySQL, then some of your tables may not be using the Dynamic row format. If you want to get the benefits of the Dynamic row format, then those tables will need to be converted to use it.
Let's convert some InnoDB tables to the Dynamic row format:
Connect to the server using MariaDB Client:
$ mariadb --user=root
Search for InnoDB tables that do not use the Dynamic row format by querying the information_
schema.INNODB_ table:SYS_ TABLES SELECT NAME, ROW_FORMAT FROM information_schema.INNODB_SYS_TABLES WHERE NAME NOT LIKE 'SYS_%' AND ROW_FORMAT != 'Dynamic';
+-------------------+------------+ | NAME | ROW_FORMAT | +-------------------+------------+ | hq_sales/invoices | Compact | +-------------------+------------+
Alter the table using the ALTER TABLE statement, and specify the Dynamic row format using the
ROW_FORMAT
table option:ALTER TABLE hq_sales.invoices ROW_FORMAT = Dynamic;
Confirm that the table uses the Dynamic row format by querying the information_
schema.INNODB_ table again:SYS_ TABLES SELECT NAME, ROW_FORMAT FROM information_schema.INNODB_SYS_TABLES WHERE NAME='hq_sales/invoices';
+-------------------+------------+ | NAME | ROW_FORMAT | +-------------------+------------+ | hq_sales/invoices | Dynamic | +-------------------+------------+