为提高效率,提问时请提供以下信息,问题描述清晰可优先响应。
- 【TiDB 版本】:v4.0.4
- 【问题描述】:
我使用Spark jdbc write往TiDB写入数据,源表有80个字段,参数设置如下:
- “isolationLevel”=“NONE”
- JDBCOptions.JDBC_BATCH_INSERT_SIZE=“1000”
- JDBC URL参数:serverTimezone=GMT%2B8&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useCursorFetch=true&rewriteBatchedStatements=true&useSSL=false"
查看tidb.log发现一直在打印报错信息“Prepared statement contains too many placeholders”:
[2020/08/19 18:06:45.351 +08:00] [ERROR] [conn.go:730] [“command dispatched failed”] [conn=76420] [connInfo=“id:76420, addr:172.16.2.70:38946 status:10, collation:utf8_general_ci, user:root”] [command=Prepare] [status=“inTxn:0, autocommit:1”] [sql=“INSERT INTO snappy_86b0590fd94743f286280665e1021b2c (id,state,create_time,update_time,group_id,shop_id,sys_customer_id,platform,customer_name,customer_state,customer_head_image,customer_from,open_card_shop_id,open_card_platform,out_id,out_nick,out_alias,member_card,sex,user_type,birthday,idcard,telphone,mobile,wechat_no,buyer_alipay_no,buyer_alipay_no_type,email,email_suffix,country,province,city,district,zip,address,is_membership,is_activate,develop_time,in_member_time,activate_time,qq,good_count,neutral_count,bad_count,is_lock_address,is_un_sub_scribe,is_member_black,right_black_str,buyer_impression,marry_status,baby_name,baby_sex,baby_birthday,job,grade,grade_modify_time,grade_relegation_time,grade_modify_way,integral_total,growth_value,es_party_time,area_region,customer_remark,open_customer_id,ext1,ext2,ext3,ext_json,sg_recruit_shop_id,sg_recruit_guide_id,sg_exclusive_shop_id,sg_exclusive_guide_id,sg_recruit_state,sg_impression,business_mark,fans_status,nx_open_id,wechat_open_id,wechat_unionid,sub_platform) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,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,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?),(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?(len: 163193)”] [txn_mode=PESSIMISTIC] [err="[executor:1390]Prepared statement contains too many placeholders"]
我想问下:虽然该报错不影响数据插入,但是否影响写入性能,如何避免该问题?
我尝试将JDBC_BATCH_INSERT_SIZE改为150后不报错,但写入速度并没有提高,如何提高写入速度?
PS:目前写入速度为:8223671行/80列 设置numPartitions=6,写入TiDB需要13分钟
若提问为性能优化、故障排查类问题,请下载脚本运行。终端输出打印结果,请务必全选并复制粘贴上传。





