By Xuandi
The traditional OLTP and OLAP solutions are based on simple read-write splitting or ETL models, extracting data from online databases into the data warehouse in the way of T+1 for calculation. With the explosive growth of data, these solutions show their weaknesses: they have high costs in storage, links, and maintenance, and have poor real-time performance. To address the challenges of explosive data growth, PolarDB-X provides the new feature Clustered Columnar Index (CCI) based on object storage. CCI supports real-time synchronization of row-oriented data to column-oriented storage and offers the following features:
PolarDB-X provides a cost-effective, real-time, and transparent HTAP (Hybrid Transaction/Analytical Processing) solution that is fully compatible with MySQL.
With the popularization of cloud-native technology, new generations of cloud-native data warehouses represented by Snowflake and the database HTAP architecture are emerging. It can be expected that the HTAP of hybrid row-column storage will become a standard capability of databases in the future. The design of column-oriented storage in the current databases needs more consideration about the low cost, ease of use, and high performance in the future.
PolarDB-X provides CCI. By default, row-oriented tables have primary/secondary key indexes. CCI is an additional column-based secondary index covering all columns of row-oriented storage. A table can have both row- and column-oriented storage data.
1. Cloud-Native Architecture (Storage-Compute Separation & Low Cost)
PolarDB-X CCI uses cloud-native OSS as the main data storage (the cost is only 1/6 to 1/10 of the local disks). CCI is competitively low in cost combined with the high compression of column-oriented data (which can be compressed 3 to 5 times). In the scenario of building HTAP hybrid row-column storage, the additional cost of column-oriented storage can be controlled within 5 to 10 percent of the row-oriented storage cost.
The storage of PolarDB-X CCI uses the two-layer model of Delta + Main (an LSM-like structure) and marked deletion technology. Therefore, CCI ensures that OSS can also update data with high concurrency. At the same time, the path for column-oriented storage to read OSS uses a multi-layer data local cache and multi-level statistics mechanism to minimize unnecessary remote OSS access.
2. Distributed Technology (Linear Scalability)
Traditional distributed databases usually build column-oriented storage based on the multi-replica mechanism of Paxos/Raft. However, the query scenarios of OLTP and OLAP have different demands and dependencies on resources. The linear scalabilities of TP and AP restrict each other and affect the performance because of the strong consistency partitioning policy and scaling mechanism between different replicas.
PolarDB-X CCI synchronizes binary logs of distributed transactions in real time and converts rows to columns (M:N). It also defines distributed partition keys and sort keys that are unique to CCI. Combined with the distributed parallel technology, CCI provides linear scalability of column-oriented storage queries. At the same time, row- and column-oriented storage are isolated from each other, and storage and computing are more elastic. Therefore, under the distributed condition, column-oriented storage can better pursue excellent linear scalability.
3. Read-Write Splitting (Serverless & Pay by Read)
The components of PolarDB-X CCI use the read-write splitting architecture. Therefore, PolarDB-X CCI has column-oriented write and read. The write nodes of column-oriented storage (columnar nodes) are stateful. They do not send write requests to the external. Instead, Columnar batches CCI data by using group commit. The read nodes of column-oriented storage (CNs) are stateless. They obtain the metadata of the column-oriented storage by using GMS nodes and directly access the CCI data on OSS.
For PolarDB-X instance creation, the system provides column-oriented write components (columnar nodes which keep running and synchronizing CCI) by default. You only need to create CCI by using the DDL syntax, and then the CCI data will be automatically built and updated in real time. Row-oriented index and CCI can be accessed by using the primary instance or purchasing a new read-only instance (CN). Stateless CN is suitable for serverless mode. You only need to pay for the use of CCI reads.
4. Hybrid Row-Column Storage (Ease of Use & Integrated and Vectorized SQL Engine)
PolarDB-X reuses the SQL engine developed by CN to provide the complete read capability of column-oriented storage. A cost optimizer is built for hybrid row-column scenarios. It intelligently identifies routes based on costs, forwarding OLTP queries to row-oriented queries, and forwarding OLAP queries to column-oriented queries. It also supports access to different row- and column-oriented queries at the SQL operator level. The hybrid row-column capability of HTAP is fully implemented to support unified access to a set of SQL engines.
PolarDB-X is fully vectorized. TableScan reads data from column-oriented storage and uses the data structure of columnar chunks. Subsequent operator computing also uses the in-memory columnar chunk structure to improve query performance based on end-to-end vectorization. In addition, TableScan for row-oriented storage is also dynamically converted into columnar chunks to implement hybrid row-column queries based on a unified data structure.
5. An All-in-One Warehouse (Zero-ETL)
Traditional data warehouses synchronize data through ETL. For complex OLAP queries, the warehouses use parallel computing architectures such as MPP/BSP. However, high-concurrency online queries such as serving scenarios have obvious resource concurrency bottlenecks. Therefore, online queries flow back with data to OLTP databases.
PolarDB-X combines AnalyticDB to provide an all-in-one warehouse. Based on the "Zero-ETL" design concept, it shares the same CCI data. Based on the data warehouse capabilities of ADB, it meets the requirements of data aggregation and data association queries of multiple parties to provide traditional warehouse and lake analysis. At the same time, for concurrent queries of online data, the HTAP hybrid row-column architecture of PolarDB-X can be used to avoid traditional data ETL in the whole process.
PolarDB-X extends the MySQL DDL syntax to define the CCI syntax. The CCI syntax is used in the same way as creating indexes in MySQL. For more information, see CCI syntax documentation.
For example:
# Create a table
CREATE TABLE t_order (
`id` bigint(11) NOT NULL AUTO_INCREMENT,
`order_id` varchar(20) DEFAULT NULL,
`buyer_id` varchar(20) DEFAULT NULL,
`seller_id` varchar(20) DEFAULT NULL,
`order_snapshot` longtext DEFAULT NULL,
`order_detail` longtext DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `l_i_order` (`order_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 partition by hash(`order_id`) partitions 16;
# Create CCI
CREATE CLUSTERED COLUMNAR INDEX `cc_i_seller` ON t_order (`seller_id`) partition by hash(`order_id`) partitions 16;
CCI is built by columnar engine nodes. The data built is eventually stored in a shared object in the CSV + ORC data format. CSV stores real-time incremental data. Excessive incremental data are quickly compacted and dumped into the ORC format. The distributed PolarDB improves both the CSV and ORC storage formats. The PolarDB-X keeps the open source characteristic of the native formats while ensuring that the two formats fully express the data protocols of MySQL.
From the perspective of data synchronization, the two parallel synchronizing paths of full snapshot reading and incremental synchronization complete the data synchronization together. CCI is built before data are imported. In this scenario, only incremental data is synchronized. Columnar nodes consume binary log data and build indexes. Part of the data are imported before CCI is built, and then the rest of the data continues to be imported. In this scenario, except for the path of incremental data synchronization, columnar nodes consume the existing full data at the same time. The parallel consumption of incremental and full data improves the efficiency of building column-oriented storage.
From the perspective of the hierarchy, the columnar engine nodes use the two-layer model of Delta + Main (an LSM-like structure). By using the marked deletion technology, the nodes ensure low latency in data synchronization between row- and column-oriented storage, and guarantee real-time updates in seconds. Data are written to MemTable in real time. In a cycle of group commit, the data are stored in a local CSV file and appended to the tail of the corresponding CSV file on OSS. This file is called the delta file. The CSV file on the OSS does not exist for a long time. It is converted into the ORC file by the compaction thread from time to time.
CN bears the traffic of PolarDB-X for query analysis.
As the preceding figure shows, the entire query acceleration includes three levels: the optimizer, the executor, and the storage engine. From the perspective of the optimizer, the PolarDB-X provides a cost-based optimizer for hybrid row-column scenarios. It identifies routes based on the cost, forwarding TP queries to row-oriented queries, and forwarding AP queries to column-oriented queries.
From the perspective of the executor, the PolarDB-X provides an integrated executor for hybrid row-column scenarios and can support HTAP scenarios. At the same time, the operator layer is vectorized to support MPP acceleration. In complex query scenarios, the layer makes full use of multi-node resources for parallel computing to meet the requirement of high throughput.
The executor layer also introduces the local cache technology to offset the network latency caused by the storage-compute separation architecture. The technology loads hot data to local disks in real time to ensure low-latency queries. From the perspective of the storage engine, the building of CCI ensures the atomicity of transaction commit and the transactional consistency of the queried data.
After the introduction of the columnar engine, the PolarDB-X adds the column-oriented read-only instance specifications to the original primary instance and read-only instance specifications.
PolarDB-X CCI provides an all-in-one HTAP experience and can be adapted to various business scenarios:
PolarDB-X and its CCI feature tackle the hybrid TP and AP scenarios with one database product. At the same time, users achieve a transparent and cost-effective HTAP solution based on cloud-native OSS and intelligent routing technologies.
TPC-H 100 GB Hardware Environment
For more operations about adding CCI online in TPC-H tables, see CCI TPC-H performance white paper.
create clustered columnar index `nation_col_index` on nation(`n_nationkey`) partition by hash(`n_nationkey`) partitions 1;
create clustered columnar index `region_col_index` on region(`r_regionkey`) partition by hash(`r_regionkey`) partitions 1;
create clustered columnar index `customer_col_index` on customer(`c_custkey`) partition by hash(`c_custkey`) partitions 24;
create clustered columnar index `part_col_index` on part(`p_size`) partition by hash(`p_partkey`) partitions 24;
create clustered columnar index `partsupp_col_index` on partsupp(`ps_partkey`) partition by hash(`ps_partkey`) partitions 24;
create clustered columnar index `supplier_col_index` on supplier(`s_suppkey`) partition by hash(`s_suppkey`) partitions 24;
create clustered columnar index `orders_col_index` on orders(`o_orderdate`,`o_orderkey`) partition by hash(`o_orderkey`) partitions 24;
create clustered columnar index `lineitem_col_index` on lineitem(`l_shipdate`,`l_orderkey`) partition by hash(`l_orderkey`) partitions 24;
The following are the running results of TPC-H based on CCI. Unit: second.
The preceding table shows the performance improvement ratio of TPC-H 100 GB based on CCI with the proportional changes of specifications, reflecting the distributed linear scalability.
PolarDB-X Best Practice Series (1): How to Design a User Table
ApsaraDB - June 19, 2024
ApsaraDB - October 16, 2024
ApsaraDB - November 12, 2024
ApsaraDB - October 16, 2024
ApsaraDB - January 3, 2024
ApsaraDB - June 4, 2024
Alibaba Cloud PolarDB for Xscale (PolarDB-X) is a cloud-native high-performance distributed database service independently developed by Alibaba Cloud.
Learn MoreAlibaba Cloud PolarDB for PostgreSQL is an in-house relational database service 100% compatible with PostgreSQL and highly compatible with the Oracle syntax.
Learn MoreAlibaba Cloud PolarDB for MySQL is a cloud-native relational database service 100% compatible with MySQL.
Learn MoreLeverage cloud-native database solutions dedicated for FinTech.
Learn MoreMore Posts by ApsaraDB