When routing, first traverse all columns, find the partition key, get the index of the partition key in the set, and get the value of the partition bias according to the index
org.apache.shardingsphere sharding-jdbc-spring-boot-starter 5.3.0

When routing, first traverse all columns, find the partition key, get the index of the partition key in the set, and get the value of the partition bias according to the index。
This will greatly improve the performance
@374639131 Thanks for your feedback, would you like to submit a PR?
feedback I want to know why sharding jdbc traverses columns many times?
@374639131 Thanks for your feedback, would you like to submit a PR?
@374639131 Thanks for your feedback, would you like to submit a PR?
I found that it takes a lot of time to find the partition key
Problem Understanding
- You reported that in sharding-jdbc-spring-boot-starter 5.3.0, INSERT routing traverses all columns to locate the sharding key, and you believe this repeated traversal causes performance overhead; you prefer pre-determining the sharding-key position and fetching the value directly.
Root Cause
- The current logic scans columns sequentially to check whether each is a sharding column and then fetches the value, without caching a “sharding column name -> column index” map or performing a single lookup. This yields an O(rows × columns) traversal cost—a performance characteristic rather than a functional bug.
Analysis
- For wide tables with large batch INSERTs, repeated column scans can add CPU/latency. Whether it is a real bottleneck depends on the workload and environment; without data we can’t confirm this is the main hotspot.
Conclusion
- To decide whether an optimization is needed, please share evidence that this step is the primary performance bottleneck—e.g., CPU/latency measurements or a flame graph showing sharding-key lookup as a significant cost. With that data we can assess and suggest a targeted improvement.
There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.