14.4.12 Temporary Tablespace

In MySQL 5.7, non-compressed, user-created InnoDB temporary tables and on-disk internal InnoDB temporary tables are created in a shared temporary tablespace. The innodb_temp_data_file_path configuration option defines the relative path, name, size, and attributes for temporary tablespace data files. If no value is specified forinnodb_temp_data_file_path, the default behavior is to create an auto-extending data file named ibtmp1 in the data directory that is slightly larger than 12MB.
在mysql5.7中,未压缩的,用户创建的的innodb临时表和磁盘上的InnoDB内部临时表都创建在共享临时表空间里面, innodb_temp_data_file_path配置选项定义了临时表空间文件相关的路径,名称,大小和属性,如果innodb_temp_data_file_path没有设置任何值,那么默认行为是在数据目录创建一个12M大小叫做ibtmp1的自动扩展数据文件,
In previous MySQL releases, temporary tables were created in individual file-per-table tablespaces in the temporary file directory, or in the InnoDB system tablespace in the data directory if innodb_file_per_table was disabled. Compressed temporary tables, which are temporary tables created using the ROW_FORMAT=COMPRESSED attribute, are still created in file-per-table tablespaces in the temporary file directory.
在以前的 MySQL 版本中, 临时表是在临时文件目录中的file-per-table表空间中创建的, 或者 innodb_file_per_table 被禁用时在数据目录的 InnoDB 系统表空间中建立的。压缩的临时表也就是是使用 ROW_FORMAT=COMPRESSED属性创建的临时表仍然在临时文件目录中的file-per-table表空间中创建。
A shared tablespace for temporary tables removes performance costs associated with creating and removing a file-per-table tablespace for each InnoDB temporary table. A dedicated tablespace for temporary tables also means that it is no longer necessary to save the metadata associated with those tables to the InnoDB system tables.
临时表的共享表空间为每个innodb临时表的创建和删除file-per-table表空间操作消除了相关的性能成本,一个专用的临时表表空间也意味着它不再需要保存与表相关的InnoDB系统表的元数据,
The shared temporary tablespace is removed on normal shutdown or on an aborted initialization, and is recreated each time the server is started. The temporary tablespace receives a dynamically generated space ID when it is created, which prevents conflicts with existing space IDs. Startup is refused if the temporary tablespace cannot be created. The temporary tablespace is not removed if the server halts unexpectedly. In this case, a database administrator can remove the temporary tablespace manually or restart the server, which removes and recreates the temporary tablespace.
在正常关机或初始化失败时会删除共享临时表空间,并且在每次服务启动的时候会重新创建,临时表空间在创建时接收动态生成的空间id,可以防止与现有空间IDs的冲突。如果不能创建临时表空间,则启动会被拒绝,临时表空间不会在服务意外终止的时候被删除,在这种情况下,数据库管理员可以手动移除临时表空间或重新启动服务器, 以删除和重创建临时表空间
The temporary tablespace cannot reside on a raw device.
临时表空间不能存放在裸设备上
INFORMATION_SCHEMA.FILES provides metadata about the InnoDB temporary tablespace. Issue a query similar to this one to view temporary tablespace metadata:
INFORMATION_SCHEMA.FILES表提供关于InnoDB的临时表空间元数据,发出类似于下面的查询,查看临时表空间元数据
mysql> SELECT * FROM INFORMATION_SCHEMA.FILES WHERE TABLESPACE_NAME='innodb_temporary'\G
INFORMATION_SCHEMA.INNODB_TEMP_TABLE_INFO provides metadata about user-created temporary tables that are currently active within an InnoDB instance. For more information, see Section 14.15.7, “InnoDB INFORMATION_SCHEMA Temporary Table Info Table”.
INFORMATION_SCHEMA.INNODB_TEMP_TABLE_INFO提供了有关在 InnoDB 实例中当前处于活动状态的用户创建的临时表的元数据,更多信息请看 Section 14.15.7, “InnoDB INFORMATION_SCHEMA Temporary Table Info Table”.
Temporary Table Undo Logs

临时表撤销日志
Temporary table undo logs are used for temporary tables and related objects. This type of undo log is not a redo log, as temporary tables are not recovered during crash recovery and do not require redo logs. Temporary table undo logs are, however, used for rollback while the server is running. This special type of non-redo undo log benefits performance by avoiding redo logging I/O for temporary tables and related objects. Temporary table undo logs reside in the temporary tablespace. 32 rollback segments are reserved for temporary table undo logs for transactions that modify temporary tables and related objects.
临时表撤销日志用于临时表和相关对象,这种类型的撤销日志不是重做日志,由于临时表在崩溃恢复期间没有恢复,因此不需要重做日志,但是,当服务器运行时,临时表撤消日志用于回滚,这种特殊的非重做撤销日志通过避免临时表和相关对象的重做日志I/O来提高性能,临时表撤销日志驻留在临时表空间中。对于修改临时表和相关对象的事务,将为临时表撤消日志保留32个回滚段。

PREV: 14.4.11 Undo Tablespace https://blog.51cto.com/itzhoujun/2353747
NEXT: 14.4.13 Redo Log https://blog.51cto.com/itzhoujun/2353749

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章