INSERT…SELECT…
statement, transmit the data back to the read-write instance through the internal network, and write the data into the target table. For a detailed feature description, see ETL Writeback Acceleration.INSERT...SELECT...
statements can be accelerated. UPDATE...SELECT...
, DELETE...SELECT...
, and other statements cannot be accelerated.INSERT…SELECT…
statement is relatively simple, reading data from the read-only analysis engine and writing the data back to the read-write instance will incur additional network overhead. The strengths are not obvious compared with the method of directly reading data from the read-write instance.INSERT…SELECT…
statement contains a large volume of data, the main performance bottleneck lies in the process of transmitting the result set over the network and writing it to the read-write instance. In this scenario, this feature cannot be used to improve performance.INSERT…SELECT…
can be accelerated.Parameter Name | Description | Default Value | Parameter Value |
libra_etl_to_rw | Controls whether to enable the writeback feature. | off | on: Enable the writeback feature. It means that writeback will be performed. off: Disable the writeback feature. When the value is off, an error of insufficient permission will be reported during INSERT…SELECT… execution. |
libra_concurrent_etl | Controls whether to enable concurrent writeback to the read-write instance. | off | on: Enable concurrent writeback. Concurrent writeback can improve the efficiency of result writeback, but transaction consistency among multiple threads cannot be guaranteed. off: Disable concurrent writeback. When the value is off, data writeback to the read-write instance will be completed in one transaction. |
libra_etl_concurrency | Controls the number of concurrent threads for data writeback to the read-write instance. This parameter takes effect only when libra_concurrent_etl is set to on. | 1 | Value range: [1–number of read-write instance CPU cores]. The value should be an integer, and the maximum value is the number of CPU cores of the read-write instance. Note: The writeback speed is high if multiple concurrent threads are used. However, a large number of concurrent threads can damage the performance of the read-write instance because it cannot withstand the write load. |
set libra_etl_to_rw=on;set libra_concurrent_etl=on;set libra_etl_concurrency=4;INSERT INTO database1.table1 select a.t1,b.t2,a.t2,b.t3 from a,b where a.t1=b.t1 and a.t5='x';set libra_concurrent_etl=off;set libra_etl_to_rw=off;
INSERT /*+ SET_VAR(libra_etl_to_rw=ON) SET_VAR(libra_concurrent_etl=ON) SET_VAR(libra_etl_concurrency=4)*/ INTO database1.table1 select a.t1,b.t2,a.t2,b.t3 from a,b where a.t1=b.t1 and a.t5='x';
set libra_etl_to_rw=on;set libra_concurrent_etl=off;set libra_etl_concurrency=1;create table t1 (supp_nation VARCHAR(50),cust_nation VARCHAR(50),l_year INT,revenue DECIMAL);INSERT INTO t1 SELECTsupp_nation, cust_nation, l_year, sum(volume) as revenuefrom (select n1.n_name as supp_nation, n2.n_name as cust_nation,extract(year from l_shipdate) as l_year,l_extendedprice * (1 - l_discount) as volumefrom supplier, lineitem, orders, customer, nation n1, nation n2where s_suppkey = l_suppkeyand o_orderkey = l_orderkeyand c_custkey = o_custkeyand s_nationkey = n1.n_nationkeyand c_nationkey = n2.n_nationkeyand ((n1.n_name = 'JAPAN' and n2.n_name = 'INDIA')or (n1.n_name = 'INDIA' and n2.n_name = 'JAPAN'))and l_shipdate between '1995-01-01' and '1996-12-31') as shippinggroup by supp_nation, cust_nation, l_yearorder by supp_nation, cust_nation, l_year;
Duration of SELECT Execution on Read-Only Analysis Engine | Writeback Feature Disabled Duration of INSERT...SELECT... Execution on Read-Write Instance | Writeback Feature Enabled Duration of INSERT...SELECT... Execution on Read-Only Analysis Engine |
0.57 | 232.77 | 0.61 |
set libra_etl_to_rw=on;set libra_concurrent_etl=off;set libra_etl_concurrency=1;CREATE TABLE t2(p_brand VARCHAR(10),p_type VARCHAR(25),p_size INTEGER,supplier_cnt INTEGER);INSERT INTO t2 SELECTp_brand,p_type,p_size,count(distinct ps_suppkey) as supplier_cntfrompartsupp,partwherep_partkey = ps_partkeyand p_brand <> 'Brand#45'and p_type not like 'MEDIUM POLISHED%'and p_size in (49, 14, 23, 45, 19, 3, 36, 9)and ps_suppkey not in (selects_suppkeyfromsupplierwheres_comment like '%Customer%Complaints%')group byp_brand,p_type,p_sizeorder bysupplier_cnt desc,p_brand,p_type,p_size;
Duration of SELECT Execution on Read-Only Analysis Engine | Writeback Feature Disabled Duration of INSERT...SELECT... Execution on Read-Write Instance | Writeback Feature Enabled Duration of INSERT...SELECT... Execution on Read-Only Analysis Engine |
0.15 | 8.77 | 0.61 |
set libra_etl_to_rw=on;set libra_concurrent_etl=on;set libra_etl_concurrency=8;CREATE TABLE IF NOT EXISTS lineitem ( L_ORDERKEY INTEGER NOT NULL,L_PARTKEY INTEGER NOT NULL,L_SUPPKEY INTEGER NOT NULL,L_LINENUMBER INTEGER NOT NULL,L_QUANTITY DECIMAL(15,2) NOT NULL,L_EXTENDEDPRICE DECIMAL(15,2) NOT NULL,L_DISCOUNT DECIMAL(15,2) NOT NULL,L_TAX DECIMAL(15,2) NOT NULL,L_RETURNFLAG CHAR(1) NOT NULL,L_LINESTATUS CHAR(1) NOT NULL,L_SHIPDATE DATE NOT NULL,L_COMMITDATE DATE NOT NULL,L_RECEIPTDATE DATE NOT NULL,L_SHIPINSTRUCT CHAR(25) NOT NULL,L_SHIPMODE CHAR(10) NOT NULL,L_COMMENT VARCHAR(44) NOT NULL , primary key(L_ORDERKEY, L_LINENUMBER));INSERT INTO lineitem_t SELECT*fromlineitem;
Number of Concurrent Threads | Writeback Feature Disabled Duration of INSERT...SELECT... Execution on Read-Write Instance | Writeback Feature Enabled Duration of INSERT...SELECT... Execution on Read-Only Analysis Engine |
Concurrent writeback disabled | 622.7 | 1441.02 |
8 concurrent threads | | 259.20 |
16 concurrent threads | | 181.79 |
32 concurrent threads | | 185.64 |