data
文件中直接写入数据的功能。旁路导入
可以绕过 SQL 层的接口,
直接在
data
文件中
直接分配空间并
插入数据,从而提高数据导入的效率。
[root@iZbp1gggy23nf8iivgw77sZ ~]# obclient -h127.0.0.1 -utest@sys -p -P2881 -Dtes
tdb -A
Enter password:
Welcome to the OceanBase. Commands end with ; or \g.
Your OceanBase connection id is 3221487620
Server version: OceanBase_CE 4.2.1.0 (r100000102023092807-7b0f43693565654bb1d7343f728bc2013dfff959) (Built Sep 28 2023 07:25:28)
Copyright (c) 2000, 2018, OceanBase and/or its affiliates. All rights reserved.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
obclient [testdb]> create table t1(c1 bigint,c2 bigint);
Query OK, 0 rows affected (0.064 sec)
obclient [testdb]> create table t1(c1 bigint,c2 bigint);
ERROR 1050 (42S01): Table 't1' already exists
obclient [testdb]> create table t2(c1 bigint,c2 bigint);
Query OK, 0 rows affected (0.044 sec)
obclient [testdb]> create table t3(c1 bigint,c2 bigint);
Query OK, 0 rows affected (0.031 sec)
obclient [testdb]> set ob_query_timeout=1000000000;
Query OK, 0 rows affected (0.000 sec)
##生成1000万记录
obclient [testdb]> insert into t1 select uniform(1,10000000,RANDOM()),uniform(1,10000000,RANDOM()) from table(generator(10000000));
Query OK, 10000000 rows affected (2 min 53.104 sec)
Records: 10000000 Duplicates: 0 Warnings: 0
## 使用普通 insert into 语句把 t1 表内数据插入到 t2 表内,耗时3分57秒
obclient [testdb]> insert /*+ enable_parallel_dml parallel(8)*/ into t2 select * from t1;
Query OK, 10000000 rows affected (3 min 57.270 sec)
Records: 10000000 Duplicates: 0 Warnings: 0
### 使用旁路导入 insert into 语句把 t1 表内数据插入到 t3 表内,耗时36秒
obclient [testdb]> insert /*+ append enable_parallel_dml parallel(8)*/ into t3 select * from t1;
Query OK, 10000000 rows affected (36.314 sec)
Records: 10000000 Duplicates: 0 Warnings: 0
###1000万条记录导入时间由237秒(3 min 57.270 sec)提升到36秒(36.314 sec),提高了6倍
总结:OB的append旁路导入数据,与oracle的append导入法类似,适用于导入大量数据的场景。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/543979/viewspace-3028731/ ,如需转载,请注明出处,否则将追究法律责任。