The PARTITIONS table provides
information about table partitions. Each row in this table
corresponds to an individual partition or subpartition of a
partitioned table. For more information about partitioning tables,
see Chapter 26, Partitioning.
The PARTITIONS table has these
columns:
TABLE_CATALOGThe name of the catalog to which the table belongs. This value is always
def.TABLE_SCHEMAThe name of the schema (database) to which the table belongs.
TABLE_NAMEThe name of the table containing the partition.
PARTITION_NAMEThe name of the partition.
SUBPARTITION_NAMEIf the
PARTITIONStable row represents a subpartition, the name of subpartition; otherwiseNULL.For
NDB: This value is alwaysNULL.PARTITION_ORDINAL_POSITIONAll partitions are indexed in the same order as they are defined, with
1being the number assigned to the first partition. The indexing can change as partitions are added, dropped, and reorganized; the number shown is this column reflects the current order, taking into account any indexing changes.SUBPARTITION_ORDINAL_POSITIONSubpartitions within a given partition are also indexed and reindexed in the same manner as partitions are indexed within a table.
PARTITION_METHODOne of the values
RANGE,LIST,HASH,LINEAR HASH,KEY, orLINEAR KEY; that is, one of the available partitioning types as discussed in Section 26.2, “Partitioning Types”.SUBPARTITION_METHODOne of the values
HASH,LINEAR HASH,KEY, orLINEAR KEY; that is, one of the available subpartitioning types as discussed in Section 26.2.6, “Subpartitioning”.PARTITION_EXPRESSIONThe expression for the partitioning function used in the
CREATE TABLEorALTER TABLEstatement that created the table's current partitioning scheme.For example, consider a partitioned table created in the
testdatabase using this statement:CREATE TABLE tp ( c1 INT, c2 INT, c3 VARCHAR(25) ) PARTITION BY HASH(c1 + c2) PARTITIONS 4;The
PARTITION_EXPRESSIONcolumn in aPARTITIONStable row for a partition from this table displaysc1 + c2, as shown here:mysql> SELECT DISTINCT PARTITION_EXPRESSION FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME='tp' AND TABLE_SCHEMA='test'; +----------------------+ | PARTITION_EXPRESSION | +----------------------+ | c1 + c2 | +----------------------+For a table that is not explicitly partitioned, this column is always
NULL, regardless of storage engine.SUBPARTITION_EXPRESSIONThis works in the same fashion for the subpartitioning expression that defines the subpartitioning for a table as
PARTITION_EXPRESSIONdoes for the partitioning expression used to define a table's partitioning.If the table has no subpartitions, this column is
NULL.PARTITION_DESCRIPTIONThis column is used for RANGE and LIST partitions. For a
RANGEpartition, it contains the value set in the partition'sVALUES LESS THANclause, which can be either an integer orMAXVALUE. For aLISTpartition, this column contains the values defined in the partition'sVALUES INclause, which is a list of comma-separated integer values.For partitions whose
PARTITION_METHODis other thanRANGEorLIST, this column is alwaysNULL.TABLE_ROWSThe number of table rows in the partition.
For partitioned
InnoDBtables, the row count given in theTABLE_ROWScolumn is only an estimated value used in SQL optimization, and may not always be exact.For
NDBtables, you can also obtain this information using the ndb_desc utility.AVG_ROW_LENGTHThe average length of the rows stored in this partition or subpartition, in bytes. This is the same as
DATA_LENGTHdivided byTABLE_ROWS.For
NDBtables, you can also obtain this information using the ndb_desc utility.DATA_LENGTHThe total length of all rows stored in this partition or subpartition, in bytes; that is, the total number of bytes stored in the partition or subpartition.
For
NDBtables, you can also obtain this information using the ndb_desc utility.MAX_DATA_LENGTHThe maximum number of bytes that can be stored in this partition or subpartition.
For
NDBtables, you can also obtain this information using the ndb_desc utility.INDEX_LENGTHThe length of the index file for this partition or subpartition, in bytes.
For partitions of
NDBtables, whether the tables use implicit or explicit partitioning, theINDEX_LENGTHcolumn value is always 0. However, you can obtain equivalent information using the ndb_desc utility.DATA_FREEThe number of bytes allocated to the partition or subpartition but not used.
For
NDBtables, you can also obtain this information using the ndb_desc utility.CREATE_TIMEThe time that the partition or subpartition was created.
UPDATE_TIMEThe time that the partition or subpartition was last modified.
CHECK_TIMEThe last time that the table to which this partition or subpartition belongs was checked.
For partitioned
InnoDBtables, the value is alwaysNULL.CHECKSUMThe checksum value, if any; otherwise
NULL.PARTITION_COMMENTThe text of the comment, if the partition has one. If not, this value is empty.
The maximum length for a partition comment is defined as 1024 characters, and the display width of the
PARTITION_COMMENTcolumn is also 1024, characters to match this limit.NODEGROUPThis is the nodegroup to which the partition belongs. For NDB Cluster tables, this is always
default. For partitioned tables using storage engines other thanNDB, the value is alsodefault. Otherwise, this column is empty.TABLESPACE_NAMEThe name of the tablespace to which the partition belongs. The value is always
DEFAULT, unless the table uses theNDBstorage engine (see the Notes at the end of this section).
Notes
PARTITIONSis a nonstandardINFORMATION_SCHEMAtable.A table using any storage engine other than
NDBand which is not partitioned has one row in thePARTITIONStable. However, the values of thePARTITION_NAME,SUBPARTITION_NAME,PARTITION_ORDINAL_POSITION,SUBPARTITION_ORDINAL_POSITION,PARTITION_METHOD,SUBPARTITION_METHOD,PARTITION_EXPRESSION,SUBPARTITION_EXPRESSION, andPARTITION_DESCRIPTIONcolumns are allNULL. Also, thePARTITION_COMMENTcolumn in this case is blank.An
NDBtable which is not explicitly partitioned has one row in thePARTITIONStable for each data node in the NDB cluster. For each such row:The
SUBPARTITION_NAME,SUBPARTITION_ORDINAL_POSITION,SUBPARTITION_METHOD,PARTITION_EXPRESSION,SUBPARTITION_EXPRESSION,CREATE_TIME,UPDATE_TIME,CHECK_TIME,CHECKSUM, andTABLESPACE_NAMEcolumns are allNULL.The
PARTITION_METHODis alwaysAUTO.The
NODEGROUPcolumn isdefault.The
PARTITION_COMMENTcolumn is empty.