ColumnStore Information Schema Tables
MariaDB ColumnStore has three Information Schema tables that expose information about the table and column storage. These tables were added in version 1.0.6 of ColumnStore.
COLUMNSTORE_TABLES
The first table is the INFORMATION_SCHMEA.COLUMNSTORE_TABLES. This contains information about the tables inside ColumnStore. The table layout is as follows:
Column | Description |
---|---|
TABLE_SCHEMA | The database schema for the table |
TABLE_NAME | The table name |
OBJECT_ID | The ColumnStore object ID for the table |
CREATION_DATE | The date the table was created |
COLUMN_COUNT | The number of columns in the table |
AUTOINCREMENT | The start autoincrement value for the table set during CREATE TABLE |
Note: Tables created with ColumnStore 1.0.4 or lower will have the year field of the creation data set incorrectly by 1900 years.
COLUMNSTORE_COLUMNS
The INFORMATION_SCHEMA.COLUMNSTORE_COLUMNS table contains information about every single column inside ColumnStore. The table layout is as follows:
Column | Description |
---|---|
TABLE_SCHEMA | The database schema for the table |
TABLE_NAME | The table name for the column |
COLUMN_NAME | The column name |
OBJECT_ID | The object ID for the column |
DICTIONARY_OBJECT_ID | The dictionary object ID for the column (NULL if there is no dictionary object |
LIST_OBJECT_ID | Placeholder for future information |
TREE_OBJECT_ID | Placeholder for future information |
DATA_TYPE | The data type for the column |
COLUMN_LENGTH | The data length for the column |
COLUMN_POSITION | The position of the column in the table, starting at 0 |
COLUMN_DEFAULT | The default value for the column |
IS_NULLABLE | Whether or not the column can be set to NULL |
NUMERIC_PRECISION | The numeric precision for the column |
NUMERIC_SCALE | The numeric scale for the column |
IS_AUTOINCREMENT | Set to 1 if the column is an autoincrement column |
COMPRESSION_TYPE | The type of compression (either "None" or "Snappy") |
COLUMNSTORE_EXTENTS
This table displays the extent map in a user consumable form. An extent is a collection of details about a section of data related to a columnstore column. A majority of columns in ColumnStore will have multiple extents and the columns table above can be joined to this one to filter results by table or column. It also contains more details about the extent in table such as file size information. The table layout is as follows:
Column | Description |
---|---|
OBJECT_ID | The object ID for the extent |
OBJECT_TYPE | Whether this is a "Column" or "Dictionary" extent |
LOGICAL_BLOCK_START | ColumnStore's internal start LBA for this extent |
LOGICAL_BLOCK_END | ColumnStore's internal end LBA for this extent |
MIN_VALUE | This minimum value stored in this extent |
MAX_VALUE | The maximum value stored in this extent |
WIDTH | The data width for the extent |
DBROOT | The DBRoot number for the extent |
PARTITION_ID | The parition ID for the extent |
SEGMENT_ID | The segment ID for the extent |
BLOCK_OFFSET | The block offset for the data file, each data file can contain multiple extents for a column |
MAX_BLOCKS | The maximum number of blocks for the extent |
HIGH_WATER_MARK | The last block committed to the extent (starting at 0) |
STATE | The state of the extent (see below) |
STATUS | The availability status for the column which is either "Available", "Unavailable" or "Out of service" |
DATA_SIZE | The uncompressed data size for the extent calculated as (HWM+1) * BLOCK_SIZE |
FILENAME | The full path and filename for the extent file, multiple extents for the same column can point to this file with different BLOCK_OFFSETs |
FILE_SIZE | The disk file size for the extent |
Notes:
- The state is "Valid" for a normal state, "Invalid" if a cpimport has completed but the table has not yet been accessed (min/max values will be invalid) or "Updating" if there is a DML statement writing to the column
- In ColumnStore the block size is 8192 bytes
- By default ColumnStore will write create an extent file of 256*1024*WIDTH bytes, if this is too small then for uncompressed data it will create a file of the maximum size for the extent (MAX_BLOCKS * BLOCK_SIZE). Snappy always compression adds a header block.
- Object IDs of less than 3000 are for internal tables and will not appears in the COLUMNSTORE_TABLES or COLUMNSTORE_COLUMNS tables
Useful Queries
The following are queries that could be considered useful with the information_schmea tables.
Column File Size By Table
This gives a total disk size of the column extents for each table, excluding dictionary sizes:
select c.table_name, sum(e1.file_size) extent_file_size from columnstore_columns c join columnstore_extents e1 on c.object_id = e1.object_id and e1.block_offset=0 group by c.table_name;
Note: This excludes the hidden internal tables.
Dictionary File Size By Table
This gives the total size for the dictionary data for a table:
select c.table_name, sum(e1.fsize) dict_file_size from columnstore_columns c join (select object_id, sum(file_size) fsize from columnstore_extents where block_offset=0 group by object_id) e1 on c.dictionary_object_id = e1.object_id group by c.table_name;
Note: This excludes the hidden internal tables.
Total File Size
This returns the total size of all the extent files including hidden internal tables:
select sum(file_size) file_size from columnstore_extents where block_offset=0;