MySQL 8 brought a significant architectural transformation by replacing the traditional MyISAM-based system tables with the Transaction Data Dictionary (TDD), a more efficient and reliable approach. This upgrade has vastly improved the management and storage of metadata, resulting in better reliability and scalability for various database objects. In this blog post, we will explore the intricacies of MySQL 8’s Transaction Data Dictionary, its advantages, and its real-life application using practical examples.

At the core of MySQL 8’s InnoDB storage engine, the Transaction Data Dictionary (TDD) plays a fundamental role in storing crucial metadata concerning database objects such as tables, indexes, constraints, triggers, and more. This innovative architecture replaces the outdated MyISAM-based system tables, effectively making the handling of data dictionary information transactional and compliant with the ACID principles.

The primary goal of the Transaction Data Dictionary (TDD) is to enhance the overall performance, stability, and scalability of MySQL databases. It achieves this by significantly reducing contention for system table locks and minimizing disk I/O, ultimately resulting in improved concurrency and heightened reliability.

In MySQL 5.7, the mysql system database was represented by a subdirectory named ‘mysql’ in the data directory. However, this mechanism was replaced in MySQL 8.0 with the more advanced Transaction Data Dictionary (TDD). The data dictionary tables are now consolidated into a single InnoDB tablespace named ‘mysql.ibd,’ residing within the MySQL data directory. It is essential for the ‘mysql.ibd’ tablespace file to remain in its designated location and retain its name, as it cannot be modified or used by any other tablespace.

The dictionary data benefits from the same protection provided to user data stored in InnoDB tables, ensuring data integrity through commit, rollback, and crash-recovery capabilities. This integration allows for more cohesive management of system data, enhancing overall database reliability and consistency.

Benefits of the Transaction Data Dictionary

Let’s explore the advantages of the MySQL 8 Transaction Data Dictionary:

  1. Atomic Transactions: The TDD ensures that database schema changes are performed as atomic transactions. This means that either all modifications related to creating or altering database objects succeed or none of them take place. As a result, the database remains consistent even if the operation encounters errors or failures.
  2. Improved Concurrency: With the removal of MyISAM-based system tables, contention for global locks is significantly reduced. As a result, multiple transactions can concurrently access and modify different parts of the data dictionary, leading to better overall performance and scalability.
  3. Crash Recovery and Data Consistency: Since the TDD records schema changes in the transaction logs, crash recovery becomes more reliable. During a crash, MySQL can replay the logged changes to ensure data consistency without relying on the MyISAM repair process.

Storing information about database objects in TDD

Now, let’s look at how the MySQL 8 Transaction Data Dictionary stores information about various database objects using examples:

Creating a New Table

Consider the following SQL query to create a simple table:

The TDD records the table’s metadata, including column names, data types, constraints, and indexes. This information is stored in transactional storage, ensuring atomicity for schema changes.

Modifying Table Structure

Let’s say we want to add a new column, “salary,” to the “employees” table:

The TDD handles this alteration as a transaction. It stores the information about the new column in a log buffer, and once the transaction is committed, the data dictionary is updated accordingly.

Indexes and Constraints

MySQL 8 TDD stores information about indexes and constraints defined on tables. For example:

This index creation is logged as a transaction in the data dictionary, making it possible to reconstruct the database’s state during recovery.

Data dictionary views

MySQL provides several data dictionary views that allow users to query metadata information directly. Some essential data dictionary views include:

INFORMATION_SCHEMA.TABLES: Provides details about tables in the database.
INFORMATION_SCHEMA.COLUMNS: Contains information about table columns.
INFORMATION_SCHEMA.INNODB_INDEXES: Provides information about indexes of InnoDB tables.
INFORMATION_SCHEMA.TABLE_CONSTRAINTS: Provides information about table constraints.

Conclusion

The MySQL 8 Transaction Data Dictionary is a game-changer in terms of managing metadata for database objects. By introducing atomic transactions and improved concurrency, it ensures better performance and data consistency. Through the examples discussed in this blog, we have seen how the TDD efficiently stores information about database objects and facilitates crash recovery.

Adopting MySQL 8 and leveraging the benefits of the Transaction Data Dictionary will undoubtedly lead to more robust and efficient database systems, making it an essential upgrade for any MySQL-based application. To know more about how to ease the major version upgrade, please check out these blogs:

 

A better way to move to MySQL 8.0! We’ll help you skip the labor-intensive upgrade process and quickly get up and running with MySQL 8.0.

 

Learn more about how Percona can help

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments