Skip to content

Commit

Permalink
更新 Doris 笔记。
Browse files Browse the repository at this point in the history
  • Loading branch information
Suomea committed Jul 9, 2024
1 parent 4a4d548 commit c1c2319
Showing 1 changed file with 12 additions and 21 deletions.
33 changes: 12 additions & 21 deletions docs/Doris/导入数据到 Doris.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ PARTITION BY RANGE(`time`)() DISTRIBUTED BY HASH(`time`) BUCKETS 8 PROPERTIES (
"dynamic_partition.time_zone"="Asia/Shanghai"
);
```
## JDBC Catalog 配合 INSERT INTO SELECT
## INSERT INTO SELECT
参考文档
1. https://doris.apache.org/zh-CN/docs/2.0/lakehouse/database/jdbc
2. https://doris.apache.org/zh-CN/docs/2.0/data-operate/import/insert-into-manual
Expand Down Expand Up @@ -109,36 +109,27 @@ insert into thermo_hygro_meter select * from mysql.iot_data.thermo_hygro_meter;

-- 或者

insert into
thermo_hygro_meter(
device_id,
detect_time,
temperature,
humidity,
create_time
)
select
device_id,
detect_time,
temperature,
humidity,
create_time
from
mysql.iot_data.thermo_hygro_meter;
insert into thermo_hygro_meter(device_id, detect_time, temperature, humidity, create_time)
select device_id, detect_time, temperature, humidity, create_time from mysql.iot_data.thermo_hygro_meter;
```

有一个问题,创建完 mysql 数据源之后,mysql 的元数据信息如表的字段列表貌似会被 Doris 缓存下来,如果 MySQL 更新了字段会导致在 Doris 中查询(`select *` 或者 `select new_field_name`)出错。
[提问链接](https://ask.selectdb.com/questions/D1ff1/jdbc-catalog-geng-xin-yuan-shu-ju-biao-zi-duan-wen-ti) 解决方案是刷新 Catalog 数据源的元数据信息,[参考链接](https://doris.apache.org/zh-CN/docs/dev/sql-manual/sql-statements/Utility-Statements/REFRESH/?_highlight=refresh)
有一个问题,创建完 mysql 数据源之后,mysql 的元数据信息如表的字段列表貌似会被 Doris 缓存下来,如果 MySQL 更新了字段会导致在 Doris 中查询(`select *` 或者 `select new_field_name`)出错。[提问链接](https://ask.selectdb.com/questions/D1ff1/jdbc-catalog-geng-xin-yuan-shu-ju-biao-zi-duan-wen-ti) 解决方案是刷新 Catalog 数据源的元数据信息,[参考链接](https://doris.apache.org/zh-CN/docs/dev/sql-manual/sql-statements/Utility-Statements/REFRESH/?_highlight=refresh)
```
REFRESH CATALOG catalog_name;
REFRESH DATABASE [catalog_name.]database_name;
REFRESH TABLE [catalog_name.][database_name.]table_name;
```

测试大量数据导入的性能
测试大量数据导入的性能

这种导入方式好像不支持 CDC。
这种导入方式好像不支持 CDC。在 2.1 版本 Doris 引入了 Job Scheduler 实现作业调度,结合 Catalog 能够实现定时同步数据的方案。

## JDBC

对于一些数据库(比如 MySQL),默认情况下 JDBC 并不总是将多个 INSERT 语句合并成一个批量插入语句发送给数据库,而是逐条发送。这会增加网络延迟和数据库处理开销。启用 `rewriteBatchedStatements` 后,JDBC 会尝试将多个 INSERT 语句合并为一个大的 INSERT 语句,以便一次性发送给数据库,从而显著提升插入效率。

Doris 在启用了 `rewriteBatchedStatements=true` 之后大批量的实时写入,还是有点慢。单次写入 2w 条数据大概耗时 20s。

## StreamLoad
参考数据导入的 [StreamLoad](https://doris.apache.org/zh-CN/docs/2.0/data-operate/import/stream-load-manual) 的方式。
## SeaTunnel

0 comments on commit c1c2319

Please sign in to comment.