Documentation Home
MySQL 9.1 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 40.4Mb
PDF (A4) - 40.5Mb
Man Pages (TGZ) - 259.5Kb
Man Pages (Zip) - 366.7Kb
Info (Gzip) - 4.1Mb
Info (Zip) - 4.1Mb


MySQL 9.1 Reference Manual  / ...  / INFORMATION_SCHEMA Tables  / INFORMATION_SCHEMA General Tables  /  The INFORMATION_SCHEMA PARTITIONS Table

28.3.21 The INFORMATION_SCHEMA PARTITIONS Table

ThePARTITIONS 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, seeChapter 26,Partitioning.

ThePARTITIONS table has these columns:

  • TABLE_CATALOG

    The name of the catalog to which the table belongs. This value is alwaysdef.

  • TABLE_SCHEMA

    The name of the schema (database) to which the table belongs.

  • TABLE_NAME

    The name of the table containing the partition.

  • PARTITION_NAME

    The name of the partition.

  • SUBPARTITION_NAME

    If thePARTITIONS table row represents a subpartition, the name of subpartition; otherwiseNULL.

    ForNDB: This value is alwaysNULL.

  • PARTITION_ORDINAL_POSITION

    All partitions are indexed in the same order as they are defined, with1 being 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_POSITION

    Subpartitions within a given partition are also indexed and reindexed in the same manner as partitions are indexed within a table.

  • PARTITION_METHOD

    One of the valuesRANGE,LIST,HASH,LINEAR HASH,KEY, orLINEAR KEY; that is, one of the available partitioning types as discussed inSection 26.2, “Partitioning Types”.

  • SUBPARTITION_METHOD

    One of the valuesHASH,LINEAR HASH,KEY, orLINEAR KEY; that is, one of the available subpartitioning types as discussed inSection 26.2.6, “Subpartitioning”.

  • PARTITION_EXPRESSION

    The expression for the partitioning function used in theCREATE TABLE orALTER TABLE statement that created the table's current partitioning scheme.

    For example, consider a partitioned table created in thetest database using this statement:

    CREATE TABLE tp (    c1 INT,    c2 INT,    c3 VARCHAR(25))PARTITION BY HASH(c1 + c2)PARTITIONS 4;

    ThePARTITION_EXPRESSION column in aPARTITIONS table 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 alwaysNULL, regardless of storage engine.

  • SUBPARTITION_EXPRESSION

    This works in the same fashion for the subpartitioning expression that defines the subpartitioning for a table asPARTITION_EXPRESSION does for the partitioning expression used to define a table's partitioning.

    If the table has no subpartitions, this column isNULL.

  • PARTITION_DESCRIPTION

    This column is used for RANGE and LIST partitions. For aRANGE partition, it contains the value set in the partition'sVALUES LESS THAN clause, which can be either an integer orMAXVALUE. For aLIST partition, this column contains the values defined in the partition'sVALUES IN clause, which is a list of comma-separated integer values.

    For partitions whosePARTITION_METHOD is other thanRANGE orLIST, this column is alwaysNULL.

  • TABLE_ROWS

    The number of table rows in the partition.

    For partitionedInnoDB tables, the row count given in theTABLE_ROWS column is only an estimated value used in SQL optimization, and may not always be exact.

    ForNDB tables, you can also obtain this information using thendb_desc utility.

  • AVG_ROW_LENGTH

    The average length of the rows stored in this partition or subpartition, in bytes. This is the same asDATA_LENGTH divided byTABLE_ROWS.

    ForNDB tables, you can also obtain this information using thendb_desc utility.

  • DATA_LENGTH

    The 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.

    ForNDB tables, you can also obtain this information using thendb_desc utility.

  • MAX_DATA_LENGTH

    The maximum number of bytes that can be stored in this partition or subpartition.

    ForNDB tables, you can also obtain this information using thendb_desc utility.

  • INDEX_LENGTH

    The length of the index file for this partition or subpartition, in bytes.

    For partitions ofNDB tables, whether the tables use implicit or explicit partitioning, theINDEX_LENGTH column value is always 0. However, you can obtain equivalent information using thendb_desc utility.

  • DATA_FREE

    The number of bytes allocated to the partition or subpartition but not used.

    ForNDB tables, you can also obtain this information using thendb_desc utility.

  • CREATE_TIME

    The time that the partition or subpartition was created.

  • UPDATE_TIME

    The time that the partition or subpartition was last modified.

  • CHECK_TIME

    The last time that the table to which this partition or subpartition belongs was checked.

    For partitionedInnoDB tables, the value is alwaysNULL.

  • CHECKSUM

    The checksum value, if any; otherwiseNULL.

  • PARTITION_COMMENT

    The 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 thePARTITION_COMMENT column is also 1024, characters to match this limit.

  • NODEGROUP

    This is the nodegroup to which the partition belongs. For NDB Cluster tables, this is alwaysdefault. For partitioned tables using storage engines other thanNDB, the value is alsodefault. Otherwise, this column is empty.

  • TABLESPACE_NAME

    The name of the tablespace to which the partition belongs. The value is alwaysDEFAULT, unless the table uses theNDB storage engine (see theNotes at the end of this section).

Notes

  • PARTITIONS is a nonstandardINFORMATION_SCHEMA table.

  • A table using any storage engine other thanNDB and which is not partitioned has one row in thePARTITIONS table. However, the values of thePARTITION_NAME,SUBPARTITION_NAME,PARTITION_ORDINAL_POSITION,SUBPARTITION_ORDINAL_POSITION,PARTITION_METHOD,SUBPARTITION_METHOD,PARTITION_EXPRESSION,SUBPARTITION_EXPRESSION, andPARTITION_DESCRIPTION columns are allNULL. Also, thePARTITION_COMMENT column in this case is blank.

  • AnNDB table which is not explicitly partitioned has one row in thePARTITIONS table for each data node in the NDB cluster. For each such row:

    • TheSUBPARTITION_NAME,SUBPARTITION_ORDINAL_POSITION,SUBPARTITION_METHOD,PARTITION_EXPRESSION,SUBPARTITION_EXPRESSION,CREATE_TIME,UPDATE_TIME,CHECK_TIME,CHECKSUM, andTABLESPACE_NAME columns are allNULL.

    • ThePARTITION_METHOD is alwaysAUTO.

    • TheNODEGROUP column isdefault.

    • ThePARTITION_COMMENT column is empty.