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

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