Closed happyi closed 2 years ago
There are 2 necessary information need to to provided:
There are 2 necessary information need to to provided:
- The version of ShardingSphere
- Did you use Statement or PreparedStatement, if PreparedStatement is used, the 1st time is slow, after 2nd times, the performance issue is better.
Hi @happyi Could you show us how you did the benchmark? If you test the performance by performing only one insert, the result may be inaccurate. https://www.oracle.com/technical-resources/articles/java/architect-benchmarking.html
Hi @happyi Could you show us how you did the benchmark? If you test the performance by performing only one insert, the result may be inaccurate. https://www.oracle.com/technical-resources/articles/java/architect-benchmarking.html
this is a comparison test with the standard jpa 。the datum point is not sharing the code like bellow
DynamicDataSourceHolder.setDataSource(DataSourceEnum.MASTER.toString());
Long startTime = System.currentTimeMillis();
String orderId = insertOrder();
log.info("不分库分表耗时:{},orderId:{}", (System.currentTimeMillis() - startTime), orderId);
orderItemRepository.deleteByOrderId(orderId);
orderRepository.deleteById(orderId);
DynamicDataSourceHolder.clearDataSource();
DynamicDataSourceHolder.setDataSource(DataSourceEnum.SHARDING.toString());
startTime = System.currentTimeMillis();
orderId = insertOrder();
log.info("分库分表总耗时:{},orderId:{}", (System.currentTimeMillis() - startTime), orderId);
DynamicDataSourceHolder.clearDataSource();
orderItemRepository.deleteByOrderId(orderId);
orderRepository.deleteById(orderId);
Hi @happyi Could you show us how you did the benchmark? If you test the performance by performing only one insert, the result may be inaccurate. https://www.oracle.com/technical-resources/articles/java/architect-benchmarking.html
this is a comparison test with the standard jpa 。the datum point is not sharing the code like bellow
DynamicDataSourceHolder.setDataSource(DataSourceEnum.MASTER.toString()); Long startTime = System.currentTimeMillis(); String orderId = insertOrder(); log.info("不分库分表耗时:{},orderId:{}", (System.currentTimeMillis() - startTime), orderId); orderItemRepository.deleteByOrderId(orderId); orderRepository.deleteById(orderId); DynamicDataSourceHolder.clearDataSource(); DynamicDataSourceHolder.setDataSource(DataSourceEnum.SHARDING.toString()); startTime = System.currentTimeMillis(); orderId = insertOrder(); log.info("分库分表总耗时:{},orderId:{}", (System.currentTimeMillis() - startTime), orderId); DynamicDataSourceHolder.clearDataSource(); orderItemRepository.deleteByOrderId(orderId); orderRepository.deleteById(orderId);
The JIT is not considered in your test. The result cannot represent the performance of ShardingSphere.
Hi @happyi Could you show us how you did the benchmark? If you test the performance by performing only one insert, the result may be inaccurate. https://www.oracle.com/technical-resources/articles/java/architect-benchmarking.html
this is a comparison test with the standard jpa 。the datum point is not sharing the code like bellow
DynamicDataSourceHolder.setDataSource(DataSourceEnum.MASTER.toString()); Long startTime = System.currentTimeMillis(); String orderId = insertOrder(); log.info("不分库分表耗时:{},orderId:{}", (System.currentTimeMillis() - startTime), orderId); orderItemRepository.deleteByOrderId(orderId); orderRepository.deleteById(orderId); DynamicDataSourceHolder.clearDataSource(); DynamicDataSourceHolder.setDataSource(DataSourceEnum.SHARDING.toString()); startTime = System.currentTimeMillis(); orderId = insertOrder(); log.info("分库分表总耗时:{},orderId:{}", (System.currentTimeMillis() - startTime), orderId); DynamicDataSourceHolder.clearDataSource(); orderItemRepository.deleteByOrderId(orderId); orderRepository.deleteById(orderId);
The JIT is not considered in your test. The result cannot represent the performance of ShardingSphere.
bulk testing get the same result
@happyi Could you share your tests and results with us? And we have done many enhancements of performance in 5.1.1, please try it.
@happyi Could you share your tests and results with us?
Can I add a wechat ?
@happyi Could you share your tests and results with us?
Can I add a wechat ?
It is better to discuss things in a public way. But if you have something unable to upload or sensitive, you may send us an Email.
@happyi Could you share your tests and results with us? And we have done many enhancements of performance in 5.1.1, please try it.
the code refer to https://github.com/happyi/sharding-test.git
We have done a lot of performance enhancements in latest version. I'm closing this.
version sharding-jdbc 5.0.0
Feature Request
the Serious performance loss like
insert into order and order_item
not sharing time :436ms sharing time 1499ms。 More than 300% loss in Multiple tests
the shardingColumn is customerId the shardingAlgorithm is HASH_MOD 。 the order and orderItem is bindingTable the code like below
the demo code refer to https://github.com/happyi/sharding-test.git