shardingsphere icon indicating copy to clipboard operation
shardingsphere copied to clipboard

mysqldump file import sharding-proxy insert speed slowly

Open lklkxcxc opened this issue 6 years ago • 9 comments

Sharding-proxy version: 4.0.0-RC3

  • Problems encountered:It took 24 hours to import 10 million records into sharding-proxy.

  • Sharding-proxy Config: start.sh -Xmx8g -Xms8g -Xmn4g,server.yaml use default parm

lklkxcxc avatar Feb 11 '20 02:02 lklkxcxc

Do you use PreparedStatement and ParameterMarker?

terrymanu avatar Feb 11 '20 05:02 terrymanu

@terrymanu : I didn't used PreparedStatement and ParameterMarker. What are PreparedStatement and ParameterMarker? database0?serverTimezone=UTC&useSSL=false&characterEncoding=utf8

use sql insert into pku_influencing_factor VALUES (0,'test','test',123.00) normal only 1 record

lklkxcxc avatar Feb 11 '20 05:02 lklkxcxc

@terrymanu Do you know why insert is so slow?

lklkxcxc avatar Feb 11 '20 05:02 lklkxcxc

Because if you don't use PreparedStatement, it will parse SQL for every call which are very slow. ShardingSphere will cache parse result if using PreparedStatement.

Please search PreparedStatement from google to get more information.

terrymanu avatar Feb 11 '20 06:02 terrymanu

@terrymanu There is not much change ,I have used param:serverTimezone=UTC&useSSL=false&characterEncoding=utf8&useServerPrepStmts=true&cachePrepStmts=true

The test is faster to import directly into backend mysql database;

lklkxcxc avatar Feb 11 '20 06:02 lklkxcxc

Terry means you can use ‘insert into pku_influencing_factor VALUES (?,?,?,?)’ with PreparedStatement and put the parameters for every record. @lklkxcxc

kimmking avatar Feb 11 '20 11:02 kimmking

@kimmking Can you give me a specific example? thank you!It isnot that how use parm useServerPrepStmts=true&cachePrepStmts=true?

@terrymanu I found add prarm rewriteBatchedStatements=true can to improve speed but still not very fast

lklkxcxc avatar Feb 11 '20 12:02 lklkxcxc

You can google or baidu PreparedStatement to find its usage.

kimmking avatar Feb 14 '20 18:02 kimmking

You can google or baidu PreparedStatement to find its usage.

@kimmking PreparedStatement can be use in sql scripts?

nevereverever avatar Mar 06 '20 01:03 nevereverever