FILES 表提供有关 MySQL 表空间数据存储文件的信息。The FILES table provides information about the
files in which MySQL tablespace data is stored.
FILES 表提供有关 InnoDB 数据文件的信息。在 NDB Cluster 中,该表还提供有关存储 NDB Cluster 磁盘表的文件的信息。有关 InnoDB 的更多信息,请参见本节稍后的 InnoDB 说明;有关 NDB Cluster 的更多信息,请参见 NDB 说明。The FILES table provides information about
InnoDB data files. In NDB Cluster, this table
also provides information about the files in which NDB Cluster
Disk Data tables are stored. For additional information specific
to InnoDB, see
InnoDB Notes, later in this section;
for additional information specific to NDB Cluster, see
NDB Notes.
FILES 表具有以下列:The FILES table has these columns:
FILE_ID对于
InnoDB:表空间 ID,也称为space_id或fil_space_t::id。ForInnoDB: The tablespace ID, also referred to as thespace_idorfil_space_t::id.对于
NDB:文件标识符。FILE_ID列的值是自动生成的。ForNDB: A file identifier.FILE_IDcolumn values are auto-generated.FILE_NAME对于
InnoDB:数据文件的名称。每表一个文件和通用表空间的文件名扩展名为.ibd。撤销表空间前缀为undo。系统表空间前缀为ibdata。全局临时表空间前缀为ibtmp。文件名包括文件路径,该路径可以相对于 MySQL 数据目录(datadir系统变量的值)来指定。ForInnoDB: The name of the data file. File-per-table and general tablespaces have an.ibdfile name extension. Undo tablespaces are prefixed byundo. The system tablespace is prefixed byibdata. The global temporary tablespace is prefixed byibtmp. The file name includes the file path, which may be relative to the MySQL data directory (the value of thedatadirsystem variable).对于
NDB:由CREATE LOGFILE GROUP或ALTER LOGFILE GROUP创建的撤消日志文件的名称,或由CREATE TABLESPACE或ALTER TABLESPACE创建的数据文件的名称。在 NDB 8.4 中,文件名显示为相对路径;对于撤消日志文件,该路径相对于目录;对于数据文件,其相对于目录DataDir/ndb_NodeId_fs/LG。这意味着,例如,使用DataDir/ndb_NodeId_fs/TSALTER TABLESPACE ts ADD DATAFILE 'data_2.dat' INITIAL SIZE 256M创建的数据文件名称将显示为./data_2.dat。ForNDB: The name of an undo log file created byCREATE LOGFILE GROUPorALTER LOGFILE GROUP, or of a data file created byCREATE TABLESPACEorALTER TABLESPACE. In NDB 8.4, the file name is shown with a relative path; for an undo log file, this path is relative to the directory; for a data file, it is relative to the directoryDataDir/ndb_NodeId_fs/LG. This means, for example, that the name of a data file created withDataDir/ndb_NodeId_fs/TSALTER TABLESPACE ts ADD DATAFILE 'data_2.dat' INITIAL SIZE 256Mis shown as./data_2.dat.FILE_TYPE对于
InnoDB:表空间文件类型。InnoDB文件有三种可能的文件类型。TABLESPACE是用于任何系统、通用或每表文件表空间文件的文件类型,这些文件包含表、索引或其他形式的用户数据。TEMPORARY是临时表空间的文件类型。UNDO LOG是撤销表空间的文件类型,用于保存撤销记录。ForInnoDB: The tablespace file type. There are three possible file types forInnoDBfiles.TABLESPACEis the file type for any system, general, or file-per-table tablespace file that holds tables, indexes, or other forms of user data.TEMPORARYis the file type for temporary tablespaces.UNDO LOGis the file type for undo tablespaces, which hold undo records.对于
NDB:值为UNDO LOG或DATAFILE之一。ForNDB: One of the valuesUNDO LOGorDATAFILE.TABLESPACE_NAME与该文件关联的表空间名称。The name of the tablespace with which the file is associated.
对于
InnoDB:通用表空间名称在创建时指定。每表独立表空间名称显示如下格式:。schema_name/table_nameInnoDB系统表空间名称为innodb_system。全局临时表空间名称为innodb_temporary。默认撤销表空间名称为innodb_undo_001和innodb_undo_002。用户创建的撤销表空间名称在创建时指定。ForInnoDB: General tablespace names are as specified when created. File-per-table tablespace names are shown in the following format:. Theschema_name/table_nameInnoDBsystem tablespace name isinnodb_system. The global temporary tablespace name isinnodb_temporary. Default undo tablespace names areinnodb_undo_001andinnodb_undo_002. User-created undo tablespace names are as specified when created.TABLE_CATALOG此值总是为空。This value is always empty.
TABLE_SCHEMA这总是
NULL。This is alwaysNULL.TABLE_NAMETABLE_NAME这总是
NULL。This is alwaysNULL.LOGFILE_GROUP_NAME对于
InnoDB:这总是NULL。ForInnoDB: This is alwaysNULL.对于
NDB:日志文件或数据文件所属的日志文件组的名称。ForNDB: The name of the log file group to which the log file or data file belongs.LOGFILE_GROUP_NUMBER对于
InnoDB:这总是NULL。ForInnoDB: This is alwaysNULL.表,如果没有任何可变长度列(
NDB: For a Disk Data undo log file, the auto-generated ID number of the log file group to which the log file belongs. This is the same as the value shown for theidcolumn in thendbinfo.dict_obj_infotable and thelog_idcolumn in thendbinfo.logspaces以及ndbinfo.logspacestables for this undo log file.ForNDB: For a Disk Data undo log file, the auto-generated ID number of the log file group to which the log file belongs. This is the same as the value shown for theidcolumn in thendbinfo.dict_obj_infotable and thelog_idcolumn in thendbinfo.logspacesandndbinfo.logspacestables for this undo log file.ENGINEENGINE对于
InnoDB:此值始终为InnoDB。ForInnoDB: This value is alwaysInnoDB.对于
NDB:该值始终为ndbcluster。ForNDB: This value is alwaysndbcluster.FULLTEXT_KEYS这总是
NULL。This is alwaysNULL.DELETED_ROWS这总是
NULL。This is alwaysNULL.UPDATE_COUNT这总是
NULL。This is alwaysNULL.FREE_EXTENTS对于
InnoDB:当前数据文件中完全空闲的区段数量。ForInnoDB: The number of fully free extents in the current data file.对于
NDB:尚未被文件使用的区段数量。ForNDB: The number of extents which have not yet been used by the file.TOTAL_EXTENTS对于
InnoDB:当前数据文件中使用的完整区段数量。文件末尾的任何部分区段不计算在内。ForInnoDB: The number of full extents used in the current data file. Any partial extent at the end of the file is not counted.对于
NDB:分配给文件的总区段数量。ForNDB: The total number of extents allocated to the file.EXTENT_SIZEEXTENT_SIZE对于
InnoDB:对于页面大小为 4KB、8KB 或 16KB 的文件,区段大小为 1048576(1MB)。对于页面大小为 32KB 的文件,区段大小为 2097152 字节(2MB),对于页面大小为 64KB 的文件,区段大小为 4194304(4MB)。FILES不报告InnoDB页面大小。页面大小由innodb_page_size系统变量定义。区段大小信息也可以从INNODB_TABLESPACES表中获取,其中FILES.FILE_ID = INNODB_TABLESPACES.SPACE。ForInnoDB: Extent size is 1048576 (1MB) for files with a 4KB, 8KB, or 16KB page size. Extent size is 2097152 bytes (2MB) for files with a 32KB page size, and 4194304 (4MB) for files with a 64KB page size.FILESdoes not reportInnoDBpage size. Page size is defined by theinnodb_page_sizesystem variable. Extent size information can also be retrieved from theINNODB_TABLESPACEStable whereFILES.FILE_ID = INNODB_TABLESPACES.SPACE.对于
NDB:文件的扩展大小(以字节为单位)。ForNDB: The size of an extent for the file in bytes.INITIAL_SIZEINITIAL_SIZE对于
InnoDB:文件的初始大小(以字节为单位)。ForInnoDB: The initial size of the file in bytes.表,如果没有任何可变长度列(
NDB: The size of the file in bytes. This is the same value that was used in theINITIAL_SIZE子句的CREATE LOGFILE GROUP,ALTER LOGFILE GROUP,CREATE TABLESPACE,或ALTER TABLESPACEstatement used to create the file.ForNDB: The size of the file in bytes. This is the same value that was used in theINITIAL_SIZEclause of theCREATE LOGFILE GROUP,ALTER LOGFILE GROUP,CREATE TABLESPACE, orALTER TABLESPACEstatement used to create the file.MAXIMUM_SIZE对于
InnoDB:文件允许的最大字节数。对于除预定义系统表空间数据文件之外的所有数据文件,该值为NULL。最大系统表空间文件大小由innodb_data_file_path定义。最大全局临时表空间文件大小由innodb_temp_data_file_path定义。预定义系统表空间数据文件的NULL值表示未明确定义文件大小限制。ForInnoDB: The maximum number of bytes permitted in the file. The value isNULLfor all data files except for predefined system tablespace data files. Maximum system tablespace file size is defined byinnodb_data_file_path. Maximum global temporary tablespace file size is defined byinnodb_temp_data_file_path. ANULLvalue for a predefined system tablespace data file indicates that a file size limit was not defined explicitly.对于
NDB:此值始终与INITIAL_SIZE值相同。ForNDB: This value is always the same as theINITIAL_SIZEvalue.AUTOEXTEND_SIZE表空间的自动扩展大小。对于
NDB,AUTOEXTEND_SIZE始终为NULL。The auto-extend size of the tablespace. ForNDB,AUTOEXTEND_SIZEis alwaysNULL.CREATION_TIME这总是
NULL。This is alwaysNULL.LAST_UPDATE_TIME这总是
NULL。This is alwaysNULL.LAST_ACCESS_TIME这总是
NULL。This is alwaysNULL.RECOVER_TIME这总是
NULL。This is alwaysNULL.TRANSACTION_COUNTER这总是
NULL。This is alwaysNULL.VERSION对于
InnoDB:这总是NULL。ForInnoDB: This is alwaysNULL.对于
NDB:文件的版本号。ForNDB: The version number of the file.ROW_FORMATROW_FORMAT对于
InnoDB:这总是NULL。ForInnoDB: This is alwaysNULL.对于
NDB:FIXED或DYNAMIC之一。ForNDB: One ofFIXEDorDYNAMIC.TABLE_ROWS这总是
NULL。This is alwaysNULL.AVG_ROW_LENGTH这总是
NULL。This is alwaysNULL.DATA_LENGTH这总是
NULL。This is alwaysNULL.MAX_DATA_LENGTH这总是
NULL。This is alwaysNULL.INDEX_LENGTH这总是
NULL。This is alwaysNULL.DATA_FREE对于
InnoDB:整个表空间的总空闲空间(以字节为单位)。预定义的系统表空间,包括系统表空间和临时表表空间,可能有一个或多个数据文件。ForInnoDB: The total amount of free space (in bytes) for the entire tablespace. Predefined system tablespaces, which include the system tablespace and temporary table tablespaces, may have one or more data files.对于
NDB:该值始终为NULL。ForNDB: This is alwaysNULL.CREATE_TIME这总是
NULL。This is alwaysNULL.UPDATE_TIME这总是
NULL。This is alwaysNULL.CHECK_TIME这总是
NULL。This is alwaysNULL.CHECKSUMCHECKSUM这总是
NULL。This is alwaysNULL.STATUSSTATUS对于
InnoDB:此值默认是NORMAL。InnoDB每表文件表空间可能报告IMPORTING,表示该表空间尚不可用。ForInnoDB: This value isNORMALby default.InnoDBfile-per-table tablespaces may reportIMPORTING, which indicates that the tablespace is not yet available.对于
NDB:对于 NDB 集群磁盘数据文件,此值始终为NORMAL。ForNDB: For NDB Cluster Disk Data files, this value is alwaysNORMAL.EXTRA对于
InnoDB:这总是NULL。ForInnoDB: This is alwaysNULL.对于
NDB:对于 undo 日志文件,此列显示 undo 日志缓冲区大小;对于数据文件,它始终为 NULL。在接下来的几段中将提供更详细的解释。ForNDB: For undo log files, this column shows the undo log buffer size; for data files, it is always NULL. A more detailed explanation is provided in the next few paragraphs.NDB在集群中的每个数据节点上存储每个数据文件和每个 undo 日志文件的副本。FILES表为每个此类文件包含一行。假设您在一个拥有四个数据节点的 NDB 集群上运行以下两个语句:NDBstores a copy of each data file and each undo log file on each data node in the cluster. TheFILEStable contains one row for each such file. Suppose that you run the following two statements on an NDB Cluster with four data nodes:CREATE LOGFILE GROUP mygroup ADD UNDOFILE 'new_undo.dat' INITIAL_SIZE 2G ENGINE NDBCLUSTER; CREATE TABLESPACE myts ADD DATAFILE 'data_1.dat' USE LOGFILE GROUP mygroup INITIAL_SIZE 256M ENGINE NDBCLUSTER;在成功运行这两个语句后,您应该会看到与针对
FILES表的查询结果类似的结果:After running these two statements successfully, you should see a result similar to the one shown here for this query against theFILEStable:mysql>
SELECT LOGFILE_GROUP_NAME, FILE_TYPE, EXTRA->FROM INFORMATION_SCHEMA.FILES->WHERE ENGINE = 'ndbcluster';+--------------------+-----------+--------------------------+ | LOGFILE_GROUP_NAME | FILE_TYPE | EXTRA | +--------------------+-----------+--------------------------+ | mygroup | UNDO LOG | UNDO_BUFFER_SIZE=8388608 | | mygroup | DATAFILE | NULL | +--------------------+-----------+--------------------------+
以下说明适用于 InnoDB 数据文件。The following notes apply to InnoDB data
files.
FILES报告的信息是从InnoDB的内存缓存中获取的,而INNODB_DATAFILES的数据则来自InnoDB的SYS_DATAFILES内部数据字典表。Information reported byFILESis obtained from theInnoDBin-memory cache for open files, whereasINNODB_DATAFILESgets its data from theInnoDBSYS_DATAFILESinternal data dictionary table.FILES提供的信息包括全局临时表空间的信息,这些信息在InnoDB的SYS_DATAFILES内部数据字典表中不可用,因此未包含在INNODB_DATAFILES中。The information provided byFILESincludes global temporary tablespace information which is not available in theInnoDBSYS_DATAFILESinternal data dictionary table, and is therefore not included inINNODB_DATAFILES.当存在独立的撤销表空间时(在 MySQL 8.4 中默认如此),撤销表空间信息会显示在
FILES中。Undo tablespace information is shown inFILESwhen separate undo tablespaces are present, as they are by default in MySQL 8.4.下面的查询返回与
InnoDB表空间相关的所有FILES表信息。The following query returns allFILEStable information relating toInnoDBtablespaces.SELECT FILE_ID, FILE_NAME, FILE_TYPE, TABLESPACE_NAME, FREE_EXTENTS, TOTAL_EXTENTS, EXTENT_SIZE, INITIAL_SIZE, MAXIMUM_SIZE, AUTOEXTEND_SIZE, DATA_FREE, STATUS FROM INFORMATION_SCHEMA.FILES WHERE ENGINE='InnoDB'\G
FILES表仅提供关于磁盘数据 文件 的信息;你不能用它来确定单个NDB表的磁盘空间分配或可用性。然而,可以使用 ndb_desc 查看存储在磁盘上的每个NDB表分配了多少空间,以及该表在磁盘上用于存储数据的可用空间还剩多少。TheFILEStable provides information about Disk Data files only; you cannot use it for determining disk space allocation or availability for individualNDBtables. However, it is possible to see how much space is allocated for eachNDBtable having data stored on disk—as well as how much remains available for storage of data on disk for that table—using ndb_desc.FILES表中包含的大部分信息也可以在ndbinfofiles表中找到。Much of the information contained in theFILEStable can also be found in thendbinfofilestable.CREATION_TIME、LAST_UPDATE_TIME和LAST_ACCESSED的值是由操作系统报告的,而不是由NDB存储引擎提供的。如果操作系统未提供值,这些列显示NULL。TheCREATION_TIME,LAST_UPDATE_TIME, andLAST_ACCESSEDvalues are as reported by the operating system, and are not supplied by theNDBstorage engine. Where no value is provided by the operating system, these columns displayNULL.TOTAL EXTENTS列和FREE_EXTENTS列之间的差值是文件当前正在使用的区段数:The difference between theTOTAL EXTENTSandFREE_EXTENTScolumns is the number of extents currently in use by the file:SELECT TOTAL_EXTENTS - FREE_EXTENTS AS extents_used FROM INFORMATION_SCHEMA.FILES WHERE FILE_NAME = './myfile.dat';要近似计算文件使用的磁盘空间量,可以将该差值乘以
EXTENT_SIZE列的值,该值表示文件中一个区段的大小(以字节为单位):To approximate the amount of disk space in use by the file, multiply that difference by the value of theEXTENT_SIZEcolumn, which gives the size of an extent for the file in bytes:SELECT (TOTAL_EXTENTS - FREE_EXTENTS) * EXTENT_SIZE AS bytes_used FROM INFORMATION_SCHEMA.FILES WHERE FILE_NAME = './myfile.dat';类似地,你可以通过将
FREE_EXTENTS乘以EXTENT_SIZE来估算给定文件中剩余的可用空间:Similarly, you can estimate the amount of space that remains available in a given file by multiplyingFREE_EXTENTSbyEXTENT_SIZE:SELECT FREE_EXTENTS * EXTENT_SIZE AS bytes_free FROM INFORMATION_SCHEMA.FILES WHERE FILE_NAME = './myfile.dat';Important前述查询产生的字节值只是近似值,其精度与
EXTENT_SIZE的值成反比。也就是说,EXTENT_SIZE值越大,近似值的准确性越低。The byte values produced by the preceding queries are approximations only, and their precision is inversely proportional to the value ofEXTENT_SIZE. That is, the largerEXTENT_SIZEbecomes, the less accurate the approximations are.同样重要的是要记住,一旦一个扩展被使用,就不能在不删除其所属数据文件的情况下再次释放。这意味着从磁盘表中删除数据不会释放磁盘空间。It is also important to remember that once an extent is used, it cannot be freed again without dropping the data file of which it is a part. This means that deletes from a Disk Data table do not release disk space.
扩展大小可以在
CREATE TABLESPACE语句中设置。欲了解更多信息,请参见第 15.1.21 节,“CREATE TABLESPACE 语句”。The extent size can be set in aCREATE TABLESPACEstatement. For more information, see Section 15.1.21, “CREATE TABLESPACE Statement”.您可以使用 ndb_desc 工具获取有关磁盘表空间的信息。有关更多信息,请参见 第 25.6.11.1 节,“NDB 集群磁盘数据对象”,以及 ndb_desc 的描述。You can obtain information about Disk Data tablespaces using the ndb_desc utility. For more information, see Section 25.6.11.1, “NDB Cluster Disk Data Objects”, as well as the description of ndb_desc.
有关更多信息以及创建、删除和获取 NDB 集群磁盘数据对象信息的示例,请参见 第 25.6.11 节,“NDB 集群磁盘表”。For additional information, and examples of creating, dropping, and obtaining information about NDB Cluster Disk Data objects, see Section 25.6.11, “NDB Cluster Disk Data Tables”.