cpimport for MariaDB Enterprise ColumnStore
MariaDB Enterprise ColumnStore includes the
cpimport utility, which efficiently bulk loads data into ColumnStore tables.
If the LOAD DATA [ LOCAL ] INFILE or INSERT INTO .. SELECT FROM .. statements are used with a ColumnStore table, MariaDB Enterprise ColumnStore transforms the operation into a bulk load that uses
cpimport by default.
Reference material is available for MariaDB Enterprise ColumnStore.
MariaDB Enterprise ColumnStore is included with MariaDB Enterprise Server.
The syntax for
$ cpimport [OPTION ...] DATABASE_NAME TABLE_NAME [INPUT_FILE]
MariaDB Enterprise ColumnStore includes the
cpimport tool for bulk data loads:
Bypasses the SQL layer to decrease overhead
Does not block read queries
Requires a write metadata lock on the table, which can be monitored with the METADATA_
LOCK_ INFO plugin
Appends the new data to the table. While the bulk load is in progress, the newly appended data is temporarily hidden from queries. After the bulk load is complete, the newly appended data is visible to queries.
Inserts each row in the order the rows are read from the source file. Users can optimize data loads for Enterprise ColumnStore's automatic partitioning by loading presorted data files.
Supports parallel distributed bulk loads
Imports data from text files
Imports data from binary files
Imports data from standard input (
For additional information, see "Data Loading with cpimport".
cpimport Options by MariaDB Enterprise ColumnStore Version
Choose a version of MariaDB Enterprise ColumnStore to see the options supported by that version:
Batch Insert Mode
MariaDB Enterprise ColumnStore enables batch insert mode by default.
When batch insert mode is enabled, MariaDB Enterprise ColumnStore, MariaDB Enterprise ColumnStore has special handling for the following statements:
Enterprise ColumnStore uses the following rules:
If the statement is executed outside of a transaction, Enterprise ColumnStore loads the data using
cpimport. It executes
cpimportusing a wrapper called
If the statement is executed inside of a transaction, Enterprise ColumnStore loads the data using the DML interface, which is slower.
Batch insert mode can be disabled by setting the columnstore_
When MariaDB Enterprise ColumnStore performs a bulk data load, it appends data to the table in the order in which the data is read. Appending data reduces the I/O requirements of bulk data loads, so that larger data sets can be loaded very efficiently.
While the bulk load is in progress, the newly appended data is temporarily hidden from queries.
After the bulk load is complete, the newly appended data is visible to queries.
Sort the Input File
When MariaDB Enterprise ColumnStore performs a bulk data load, it appends data to the table in the order in which the data is read.
The order of data can have a significant effect on performance with Enterprise ColumnStore, so it can be helpful to sort the data in the input file prior to importing it.
For additional information, see "Load Ordered Data in Proper Order".
MariaDB Enterprise ColumnStore requires a write metadata lock (MDL) on the table when a bulk data load is performed with cpimport.
When a bulk data load is running:
Read queries will not be blocked.
Write queries and concurrent bulk data loads on the same table will be blocked until the bulk data load operation is complete, and the write metadata lock on the table has been released.
The write metadata lock (MDL) can be monitored with the METADATA_
LOCK_. INFO plugin
cpimport tool writes bulk load logs to different directories, depending on the version of MariaDB Enterprise ColumnStore:
In Enterprise ColumnStore 5.5.2 and later, logs are written to
In Enterprise ColumnStore 5 releases before 5.5.2, logs are written to
In Enterprise ColumnStore 1.4, logs are written to
Import from Text Files
cpimport tool can import data from a text file if a file is provided as an argument after the database and table name.
For example, to import the file
inventory-products.txt into the
products table in the
$ sudo cpimport \ inventory products \ inventory-products.txt
Import from Remote MariaDB Server
cpimport tool can import data from a remote MariaDB Server. You can use MariaDB Client to query the table using the SELECT statement, and then pipe the results into the standard input of the
$ mariadb --quick \ --skip-column-names \ --execute="SELECT * FROM inventory.products" \ | cpimport -s '\t' inventory products
Import from an S3 Bucket
cpimport tool can import data from a file stored in a remote S3 bucket. You can use the AWS CLI to copy the file from S3, and then pipe the contents into the standard input of the
$ aws s3 cp --quiet s3://columnstore-test/inventory-products.csv - \ | cpimport -s ',' inventory products
Set the Field Delimiter
The default field delimiter for the
cpimport tool is a pipe (
If your data file uses a different field delimiter, you can specify the field delimiter with the
For a TSV (tab-separated values) file:
$ sudo cpimport -s '\t' \ inventory products \ inventory-products.tsv
For a CSV (comma-separated values) file:
$ sudo cpimport -s ',' \ inventory products \ inventory-products.csv
Set the Quoting Style
By default, the
cpimport tool does not expect fields to be quoted.
If your data file uses quotes around fields, you can specify the quote character with the
To load a TSV (tab-separated values) file that uses double quotes:
$ sudo cpimport -s '\t' -E '"' \ inventory products \ inventory-products.tsv
To load a CSV (comma-separated values) file that uses optional single quotes:
$ sudo cpimport -s ',' -E "'" \ inventory products \ inventory-products.csv