当前位置:网站首页>spark 寫入doris太慢方案解决
spark 寫入doris太慢方案解决
2022-06-09 11:46:00 【菜鳥蜀黍】
最近公司用到了spark讀寫doris,因為doris其實就是mysql協議,在讀取數據時候速度還是可以的,但是寫入時候就發生了數據寫入特別慢,幾千條的數據甚至要用幾十分鐘,這不是可以接受的。
經過調研查詢發現因為連接參數沒有指定,數據都是單條寫入,改造前寫入方式:
userLogDF
.write
.format("jdbc")
.mode(SaveMode.Append)
.option("driver", "com.mysql.jdbc.Driver")
.option("url", "jdbc:mysql://${host}:${port}")
.option("batchsize", "50000")
.option("user", "root")
.option("password", "bigdata1234")
.option("isolationLevel", "NONE")
.option("dbtable","dev_dwd.dwd_user_act" )
.save()
而需要增加的參數就是在URL後增加,單錶重複批量寫入,而不是單條的循環寫入
rewriteBatchedStatements=true
改造後:
userLogDF
.write
.format("jdbc")
.mode(SaveMode.Append)
.option("driver", "com.mysql.jdbc.Driver")
.option("url", "jdbc:mysql://${host}:${port}/dev_dwd?rewriteBatchedStatements=true")
.option("batchsize", "50000")
.option("user", "root")
.option("password", "bigdata1234")
.option("isolationLevel", "NONE")
.option("dbtable","dev_dwd.dwd_user_act" )
.save()
寫入速度又原先的幾十分鐘變為了幾十秒。
边栏推荐
- [buuctf.reverse] 103_ [CFI-CTF 2018]powerPacked
- 给DNS划重点:分析ISC BIND必知必会
- 百度 90 后程序员删改数据库被判刑,其称因对领导不满
- Kaggle Titanic survivor forecast
- CTFshow之web171~180---SQL注入(1)
- [buuctf.reverse] 105_[FlareOn6]Memecat Battlestation
- CTFshow之web89~web96---php特性(1)
- [basic knowledge] ~ hard core / soft core / solid core, pwm/spwm, Fibonacci sequence, large end mode storage, Fourier transform, Nyquist sampling law, chip selection, Kirchhoff law, fir/iir filter
- (critical) chassis-frontend. c:122: Failed to get log directory, please set by --log-path
- P1110 [ZJOI2007]报表统计
猜你喜欢

Possible causes of processing chain loading error -process chain loading error

首家BMW i品牌专属体验店开业,全面展示宝马电动产品的魅力

The most complete knowledge summary, which must be read by beginners

Chapter II Application Layer

【SignalR全套系列】之在.Net Core 中实现SignalR实时通信

CTF platform marsctf after graduation

iphone5s显示被停用了解决办法

详解PCB线路板覆铜基础知识

Record of a memory leak

Jingzhida rushes to the scientific innovation board: the annual revenue is 458million, and the SME fund is the shareholder
随机推荐
win10你的组织已关闭自动更新问题怎么解决?
[basic knowledge] ~ hard core / soft core / solid core, pwm/spwm, Fibonacci sequence, large end mode storage, Fourier transform, Nyquist sampling law, chip selection, Kirchhoff law, fir/iir filter
On event loop
RestTemplate使用详解及踩坑记录
flex:1不等分的问题
P5482 [jloi2011] inequality system, cckk
电脑的选择1
R语言使用t.test函数对不同分组对应的目标变量的均值进行Welch双样本t检验分析、双独立样本t检验
[buuctf.reverse] 103_ [CFI-CTF 2018]powerPacked
Apple claims that M2 is 26 times stronger than Intel i5. The truth of false marketing has been revealed!
[basic knowledge] ~ zener diode, triode, amplification circuit, number of logic gate transistors, FPGA device junction temperature range, FPGA loading mode, Schmitt trigger, C language structured prog
[buuctf.reverse] 107_ [FlareOn4]greek_ to_ me
ref引用用法
Wsl2 environment setup
[SystemVerilog data type] ~ data type, logic type, array
2021年下半年系统集成项目管理工程师案例分析真题及答案解析
Win11正式发布新功能
IPv6 地址分配
P4580 [bjoi2014] path
The most complete knowledge summary, which must be read by beginners