<h2 dir="auto">Bug Report</h2>
<p dir="auto"><strong>For English only</strong>, other languages will not accept.</p>
<p dir="auto">Before report a bug, make sure you have:</p>
<ul dir="auto">
<li>Searched open and closed <a href="https://github.com/apache/shardingsphere/issues">GitHub issues</a>.</li>
<li>Read documentation: <a href="https://shardingsphere.apache.org/document/current/en/overview" rel="nofollow">ShardingSphere Doc</a>.</li>
</ul>
<p dir="auto">Please pay attention on issues you submitted, because we maybe need more details.<br>
If no response anymore and we cannot reproduce it on current information, we will <strong>close it</strong>.</p>
<p dir="auto">Please answer these questions before submitting your issue. Thanks!</p>
<h3 dir="auto">Which version of ShardingSphere did you use?</h3>
<p dir="auto">5.0.1-SNAPSHOT<br>
master<br>
commit <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/apache/shardingsphere/commit/654c876aff05c8d51261e9ffb8d46f884fb685c7/hovercard" href="https://github.com/apache/shardingsphere/commit/654c876aff05c8d51261e9ffb8d46f884fb685c7"><tt>654c876</tt></a></p>
<h3 dir="auto">Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?</h3>
<p dir="auto">ShardingSphere-Proxy</p>
<h3 dir="auto">Expected behavior</h3>
<p dir="auto">without error</p>
<h3 dir="auto">Actual behavior</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[ERROR] 2021-11-25 21:46:41.736 [epollEventLoopGroup-3-5] o.a.s.p.f.n.FrontendChannelInboundHandler - Exception occur:
java.lang.IndexOutOfBoundsException: readerIndex(1) + length(4) exceeds writerIndex(4): PooledSlicedByteBuf(ridx: 1, widx: 4, cap: 4/4, unwrapped: PooledUnsafeDirectByteBuf(ridx: 7, widx: 19, cap: 2048))
	at io.netty.buffer.AbstractByteBuf.checkReadableBytes0(AbstractByteBuf.java:1442)
	at io.netty.buffer.AbstractByteBuf.readIntLE(AbstractByteBuf.java:817)
	at org.apache.shardingsphere.db.protocol.mysql.payload.MySQLPacketPayload.readInt4(MySQLPacketPayload.java:115)
	at org.apache.shardingsphere.db.protocol.mysql.packet.handshake.MySQLHandshakeResponse41Packet.&lt;init&gt;(MySQLHandshakeResponse41Packet.java:56)
	at org.apache.shardingsphere.proxy.frontend.mysql.authentication.MySQLAuthenticationEngine.authPhaseFastPath(MySQLAuthenticationEngine.java:88)
	at org.apache.shardingsphere.proxy.frontend.mysql.authentication.MySQLAuthenticationEngine.authenticate(MySQLAuthenticationEngine.java:75)
	at org.apache.shardingsphere.proxy.frontend.netty.FrontendChannelInboundHandler.authenticate(FrontendChannelInboundHandler.java:80)
	at org.apache.shardingsphere.proxy.frontend.netty.FrontendChannelInboundHandler.channelRead(FrontendChannelInboundHandler.java:72)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324)
	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:311)
	at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:432)
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276)
	at io.netty.handler.codec.ByteToMessageCodec.channelRead(ByteToMessageCodec.java:103)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
	at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:795)
	at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:480)
	at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:378)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.lang.Thread.run(Thread.java:748)
[ERROR] 2021-11-25 21:46:41.745 [epollEventLoopGroup-3-5] o.a.s.p.f.n.FrontendChannelInboundHandler - Exception occur:
java.lang.IndexOutOfBoundsException: readerIndex(1) + length(4) exceeds writerIndex(1): PooledSlicedByteBuf(ridx: 1, widx: 1, cap: 1/1, unwrapped: PooledUnsafeDirectByteBuf(ridx: 11, widx: 19, cap: 2048))
	at io.netty.buffer.AbstractByteBuf.checkReadableBytes0(AbstractByteBuf.java:1442)
	at io.netty.buffer.AbstractByteBuf.readIntLE(AbstractByteBuf.java:817)
	at org.apache.shardingsphere.db.protocol.mysql.payload.MySQLPacketPayload.readInt4(MySQLPacketPayload.java:115)
	at org.apache.shardingsphere.db.protocol.mysql.packet.handshake.MySQLHandshakeResponse41Packet.&lt;init&gt;(MySQLHandshakeResponse41Packet.java:56)
	at org.apache.shardingsphere.proxy.frontend.mysql.authentication.MySQLAuthenticationEngine.authPhaseFastPath(MySQLAuthenticationEngine.java:88)
	at org.apache.shardingsphere.proxy.frontend.mysql.authentication.MySQLAuthenticationEngine.authenticate(MySQLAuthenticationEngine.java:75)
	at org.apache.shardingsphere.proxy.frontend.netty.FrontendChannelInboundHandler.authenticate(FrontendChannelInboundHandler.java:80)
	at org.apache.shardingsphere.proxy.frontend.netty.FrontendChannelInboundHandler.channelRead(FrontendChannelInboundHandler.java:72)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324)
	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:311)
	at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:432)
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276)
	at io.netty.handler.codec.ByteToMessageCodec.channelRead(ByteToMessageCodec.java:103)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
	at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:795)
	at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:480)
	at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:378)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.lang.Thread.run(Thread.java:748)"><pre class="notranslate"><code class="notranslate">[ERROR] 2021-11-25 21:46:41.736 [epollEventLoopGroup-3-5] o.a.s.p.f.n.FrontendChannelInboundHandler - Exception occur:
java.lang.IndexOutOfBoundsException: readerIndex(1) + length(4) exceeds writerIndex(4): PooledSlicedByteBuf(ridx: 1, widx: 4, cap: 4/4, unwrapped: PooledUnsafeDirectByteBuf(ridx: 7, widx: 19, cap: 2048))
	at io.netty.buffer.AbstractByteBuf.checkReadableBytes0(AbstractByteBuf.java:1442)
	at io.netty.buffer.AbstractByteBuf.readIntLE(AbstractByteBuf.java:817)
	at org.apache.shardingsphere.db.protocol.mysql.payload.MySQLPacketPayload.readInt4(MySQLPacketPayload.java:115)
	at org.apache.shardingsphere.db.protocol.mysql.packet.handshake.MySQLHandshakeResponse41Packet.&lt;init&gt;(MySQLHandshakeResponse41Packet.java:56)
	at org.apache.shardingsphere.proxy.frontend.mysql.authentication.MySQLAuthenticationEngine.authPhaseFastPath(MySQLAuthenticationEngine.java:88)
	at org.apache.shardingsphere.proxy.frontend.mysql.authentication.MySQLAuthenticationEngine.authenticate(MySQLAuthenticationEngine.java:75)
	at org.apache.shardingsphere.proxy.frontend.netty.FrontendChannelInboundHandler.authenticate(FrontendChannelInboundHandler.java:80)
	at org.apache.shardingsphere.proxy.frontend.netty.FrontendChannelInboundHandler.channelRead(FrontendChannelInboundHandler.java:72)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324)
	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:311)
	at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:432)
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276)
	at io.netty.handler.codec.ByteToMessageCodec.channelRead(ByteToMessageCodec.java:103)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
	at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:795)
	at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:480)
	at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:378)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.lang.Thread.run(Thread.java:748)
[ERROR] 2021-11-25 21:46:41.745 [epollEventLoopGroup-3-5] o.a.s.p.f.n.FrontendChannelInboundHandler - Exception occur:
java.lang.IndexOutOfBoundsException: readerIndex(1) + length(4) exceeds writerIndex(1): PooledSlicedByteBuf(ridx: 1, widx: 1, cap: 1/1, unwrapped: PooledUnsafeDirectByteBuf(ridx: 11, widx: 19, cap: 2048))
	at io.netty.buffer.AbstractByteBuf.checkReadableBytes0(AbstractByteBuf.java:1442)
	at io.netty.buffer.AbstractByteBuf.readIntLE(AbstractByteBuf.java:817)
	at org.apache.shardingsphere.db.protocol.mysql.payload.MySQLPacketPayload.readInt4(MySQLPacketPayload.java:115)
	at org.apache.shardingsphere.db.protocol.mysql.packet.handshake.MySQLHandshakeResponse41Packet.&lt;init&gt;(MySQLHandshakeResponse41Packet.java:56)
	at org.apache.shardingsphere.proxy.frontend.mysql.authentication.MySQLAuthenticationEngine.authPhaseFastPath(MySQLAuthenticationEngine.java:88)
	at org.apache.shardingsphere.proxy.frontend.mysql.authentication.MySQLAuthenticationEngine.authenticate(MySQLAuthenticationEngine.java:75)
	at org.apache.shardingsphere.proxy.frontend.netty.FrontendChannelInboundHandler.authenticate(FrontendChannelInboundHandler.java:80)
	at org.apache.shardingsphere.proxy.frontend.netty.FrontendChannelInboundHandler.channelRead(FrontendChannelInboundHandler.java:72)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324)
	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:311)
	at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:432)
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276)
	at io.netty.handler.codec.ByteToMessageCodec.channelRead(ByteToMessageCodec.java:103)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
	at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:795)
	at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:480)
	at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:378)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.lang.Thread.run(Thread.java:748)
</code></pre></div>
<h3 dir="auto">Reason analyze (If you can)</h3>
<h3 dir="auto">Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.</h3>
<ul dir="auto">
<li><a href="https://hub.fastgit.org/pingcap/benchmarksql.git" rel="nofollow">https://hub.fastgit.org/pingcap/benchmarksql.git</a></li>
<li>5.0-mysql-support-opt-2.1</li>
</ul>
<h3 dir="auto">Example codes for reproduce this issue (such as a github link).</h3>
<h1 dir="auto">BenchmarkSQL with ShardingSphere-Proxy</h1>
<h2 dir="auto">BenchmarkSQL</h2>
<p dir="auto"><a href="https://hub.fastgit.org/pingcap/benchmarksql.git" rel="nofollow">https://hub.fastgit.org/pingcap/benchmarksql.git</a><br>
5.0-mysql-support-opt-2.1</p>
<h2 dir="auto">MySQL</h2>
<p dir="auto">Version：5.7.26  Port：3306</p>
<h2 dir="auto">ShardingSphere-Proxy</h2>
<p dir="auto"><a href="https://github.com.cnpmjs.org/apache/shardingsphere.git" rel="nofollow">https://github.com.cnpmjs.org/apache/shardingsphere.git</a><br>
master<br>
commit <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/apache/shardingsphere/commit/654c876aff05c8d51261e9ffb8d46f884fb685c7/hovercard" href="https://github.com/apache/shardingsphere/commit/654c876aff05c8d51261e9ffb8d46f884fb685c7"><tt>654c876</tt></a></p>
<h2 dir="auto">About ShardingSphere-Proxy</h2>
<h3 dir="auto">server.yaml</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="rules:
  - !AUTHORITY
    users:
      - root@%:root
      - sharding@:sharding
    provider:
      type: NATIVE


props:
  #max-connections-size-per-query: 1
  #executor-size: 16  # Infinite by default.
  #proxy-frontend-flush-threshold: 128  # The default value is 128.
  #proxy-opentracing-enabled: false
  #proxy-hint-enabled: false
  #sql-show: false
  #check-table-metadata-enabled: false
  #lock-wait-timeout-milliseconds: 50000 # The maximum time to wait for a lock
    # Proxy backend query fetch size. A larger value may increase the memory usage of ShardingSphere Proxy.
    # The default value is -1, which means set the minimum value for different JDBC drivers.
  #proxy-backend-query-fetch-size: 200
  #check-duplicate-table-enabled: false
  proxy-frontend-executor-size: 200 # Proxy frontend executor size. The default value is 0, which means let Netty decide.
    # Available options of proxy backend executor suitable: OLAP(default), OLTP. The OLTP option may reduce time cost of writing packets to client, but it may increase the latency of SQL xecution
    # if client connections are more than proxy-frontend-netty-executor-size, especially executing slow SQL.
  proxy-backend-executor-suitable: OLTP"><pre class="notranslate"><code class="notranslate">rules:
  - !AUTHORITY
    users:
      - root@%:root
      - sharding@:sharding
    provider:
      type: NATIVE


props:
  #max-connections-size-per-query: 1
  #executor-size: 16  # Infinite by default.
  #proxy-frontend-flush-threshold: 128  # The default value is 128.
  #proxy-opentracing-enabled: false
  #proxy-hint-enabled: false
  #sql-show: false
  #check-table-metadata-enabled: false
  #lock-wait-timeout-milliseconds: 50000 # The maximum time to wait for a lock
    # Proxy backend query fetch size. A larger value may increase the memory usage of ShardingSphere Proxy.
    # The default value is -1, which means set the minimum value for different JDBC drivers.
  #proxy-backend-query-fetch-size: 200
  #check-duplicate-table-enabled: false
  proxy-frontend-executor-size: 200 # Proxy frontend executor size. The default value is 0, which means let Netty decide.
    # Available options of proxy backend executor suitable: OLAP(default), OLTP. The OLTP option may reduce time cost of writing packets to client, but it may increase the latency of SQL xecution
    # if client connections are more than proxy-frontend-netty-executor-size, especially executing slow SQL.
  proxy-backend-executor-suitable: OLTP
</code></pre></div>
<h3 dir="auto">config-sharding.yaml</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="schemaName: proxy_tpcc
dataSources:
  ds_0:
    url: jdbc:mysql://IP.10.21:3306/tpcc0
    username: root
    password: Passwd
    connectionTimeoutMilliseconds: 3000
    idleTimeoutMilliseconds: 60000
    maxLifetimeMilliseconds: 1800000
    maxPoolSize: 200
    minPoolSize: 0
  ds_1:
    url: jdbc:mysql://IP.10.21:3306/tpcc1
    username: root
    password: Passwd
    connectionTimeoutMilliseconds: 3000
    idleTimeoutMilliseconds: 60000
    maxLifetimeMilliseconds: 1800000
    maxPoolSize: 200
    minPoolSize: 0
  ds_2:
    url: jdbc:mysql://IP.10.21:3306/tpcc2
    username: root
    password: Passwd
    connectionTimeoutMilliseconds: 3000
    idleTimeoutMilliseconds: 60000
    maxLifetimeMilliseconds: 1800000
    maxPoolSize: 200
    minPoolSize: 0
  ds_3:
    url: jdbc:mysql://IP.10.21:3306/tpcc3
    username: root
    password: Passwd
    connectionTimeoutMilliseconds: 3000
    idleTimeoutMilliseconds: 60000
    maxLifetimeMilliseconds: 1800000
    maxPoolSize: 200
    minPoolSize: 0
  ds_4:
    url: jdbc:mysql://IP.10.21:3306/tpcc4
    username: root
    password: Passwd
    connectionTimeoutMilliseconds: 3000
    idleTimeoutMilliseconds: 60000
    maxLifetimeMilliseconds: 1800000
    maxPoolSize: 200
    minPoolSize: 0

rules:
  - !SHARDING
    bindingTables:
    #  - bmsql_warehouse, bmsql_customer
    #  - bmsql_stock, bmsql_district, bmsql_order_line
      -  bmsql_district, bmsql_order_line
    defaultDatabaseStrategy:
      none: null
    defaultTableStrategy:
      none: null
    keyGenerators:
      snowflake:
        props:
          worker-id: 123
        type: SNOWFLAKE
    shardingAlgorithms:
      ds_bmsql_customer_inline:
        props:
          algorithm-expression: ds_${c_id % 5}
        type: INLINE
      ds_bmsql_district_inline:
        props:
          algorithm-expression: ds_${d_w_id % 5}
        type: INLINE
      ds_bmsql_history_inline:
        props:
          algorithm-expression: ds_${h_w_id % 5}
        type: INLINE
      ds_bmsql_item_inline:
        props:
          algorithm-expression: ds_${i_id % 5}
        type: INLINE
      ds_bmsql_new_order_inline:
        props:
          algorithm-expression: ds_${no_w_id % 5}
        type: INLINE
      ds_bmsql_oorder_inline:
        props:
          algorithm-expression: ds_${o_w_id % 5}
        type: INLINE
      ds_bmsql_order_line_inline:
        props:
          algorithm-expression: ds_${ol_w_id % 5}
        type: INLINE
      ds_bmsql_stock_inline:
        props:
          algorithm-expression: ds_${s_w_id % 5}
        type: INLINE
      ds_bmsql_warehouse_inline:
        props:
          algorithm-expression: ds_${w_id % 5}
        type: INLINE

      t_bmsql_item:
        type: INLINE
        props:
          algorithm-expression: bmsql_item_${i_im_id % 2}
      t_bmsql_order_line:
        type: INLINE
        props:
          algorithm-expression: bmsql_order_line_${ol_number % 6}


    tables:
      bmsql_config:
        actualDataNodes: ds_0.bmsql_config
      bmsql_customer:
        actualDataNodes: ds_${0..4}.bmsql_customer
        # tableStrategy:
        #   standard:
        #     shardingColumn: c_id
        #     shardingAlgorithmName: t_bmsql_customer
        databaseStrategy:
          standard:
            shardingAlgorithmName: ds_bmsql_customer_inline
            shardingColumn: c_id
      bmsql_district:
        actualDataNodes: ds_${0..4}.bmsql_district
        databaseStrategy:
          standard:
            shardingAlgorithmName: ds_bmsql_district_inline
            shardingColumn: d_w_id
      bmsql_history:
        actualDataNodes: ds_${0..4}.bmsql_history
        databaseStrategy:
          standard:
            shardingAlgorithmName: ds_bmsql_history_inline
            shardingColumn: h_w_id
      bmsql_item:
        actualDataNodes: ds_${0..4}.bmsql_item_${0..1}
        tableStrategy:
          standard:
            shardingColumn: i_im_id
            shardingAlgorithmName: t_bmsql_item
        databaseStrategy:
          standard:
            shardingAlgorithmName: ds_bmsql_item_inline
            shardingColumn: i_id
      bmsql_new_order:
        actualDataNodes: ds_${0..4}.bmsql_new_order
        databaseStrategy:
          standard:
            shardingAlgorithmName: ds_bmsql_new_order_inline
            shardingColumn: no_w_id
      bmsql_oorder:
        actualDataNodes: ds_${0..4}.bmsql_oorder
        databaseStrategy:
          standard:
            shardingAlgorithmName: ds_bmsql_oorder_inline
            shardingColumn: o_w_id
      bmsql_order_line:
        actualDataNodes: ds_${0..4}.bmsql_order_line_${0..5}
        tableStrategy:
          standard:
            shardingColumn: ol_number
            shardingAlgorithmName: t_bmsql_order_line
        databaseStrategy:
          standard:
            shardingAlgorithmName: ds_bmsql_order_line_inline
            shardingColumn: ol_w_id
      bmsql_stock:
        actualDataNodes: ds_${0..4}.bmsql_stock
        databaseStrategy:
          standard:
            shardingAlgorithmName: ds_bmsql_stock_inline
            shardingColumn: s_w_id
      bmsql_warehouse:
        actualDataNodes: ds_${0..4}.bmsql_warehouse
        databaseStrategy:
          standard:
            shardingAlgorithmName: ds_bmsql_warehouse_inline
            shardingColumn: w_id"><pre class="notranslate"><code class="notranslate">schemaName: proxy_tpcc
dataSources:
  ds_0:
    url: jdbc:mysql://IP.10.21:3306/tpcc0
    username: root
    password: Passwd
    connectionTimeoutMilliseconds: 3000
    idleTimeoutMilliseconds: 60000
    maxLifetimeMilliseconds: 1800000
    maxPoolSize: 200
    minPoolSize: 0
  ds_1:
    url: jdbc:mysql://IP.10.21:3306/tpcc1
    username: root
    password: Passwd
    connectionTimeoutMilliseconds: 3000
    idleTimeoutMilliseconds: 60000
    maxLifetimeMilliseconds: 1800000
    maxPoolSize: 200
    minPoolSize: 0
  ds_2:
    url: jdbc:mysql://IP.10.21:3306/tpcc2
    username: root
    password: Passwd
    connectionTimeoutMilliseconds: 3000
    idleTimeoutMilliseconds: 60000
    maxLifetimeMilliseconds: 1800000
    maxPoolSize: 200
    minPoolSize: 0
  ds_3:
    url: jdbc:mysql://IP.10.21:3306/tpcc3
    username: root
    password: Passwd
    connectionTimeoutMilliseconds: 3000
    idleTimeoutMilliseconds: 60000
    maxLifetimeMilliseconds: 1800000
    maxPoolSize: 200
    minPoolSize: 0
  ds_4:
    url: jdbc:mysql://IP.10.21:3306/tpcc4
    username: root
    password: Passwd
    connectionTimeoutMilliseconds: 3000
    idleTimeoutMilliseconds: 60000
    maxLifetimeMilliseconds: 1800000
    maxPoolSize: 200
    minPoolSize: 0

rules:
  - !SHARDING
    bindingTables:
    #  - bmsql_warehouse, bmsql_customer
    #  - bmsql_stock, bmsql_district, bmsql_order_line
      -  bmsql_district, bmsql_order_line
    defaultDatabaseStrategy:
      none: null
    defaultTableStrategy:
      none: null
    keyGenerators:
      snowflake:
        props:
          worker-id: 123
        type: SNOWFLAKE
    shardingAlgorithms:
      ds_bmsql_customer_inline:
        props:
          algorithm-expression: ds_${c_id % 5}
        type: INLINE
      ds_bmsql_district_inline:
        props:
          algorithm-expression: ds_${d_w_id % 5}
        type: INLINE
      ds_bmsql_history_inline:
        props:
          algorithm-expression: ds_${h_w_id % 5}
        type: INLINE
      ds_bmsql_item_inline:
        props:
          algorithm-expression: ds_${i_id % 5}
        type: INLINE
      ds_bmsql_new_order_inline:
        props:
          algorithm-expression: ds_${no_w_id % 5}
        type: INLINE
      ds_bmsql_oorder_inline:
        props:
          algorithm-expression: ds_${o_w_id % 5}
        type: INLINE
      ds_bmsql_order_line_inline:
        props:
          algorithm-expression: ds_${ol_w_id % 5}
        type: INLINE
      ds_bmsql_stock_inline:
        props:
          algorithm-expression: ds_${s_w_id % 5}
        type: INLINE
      ds_bmsql_warehouse_inline:
        props:
          algorithm-expression: ds_${w_id % 5}
        type: INLINE

      t_bmsql_item:
        type: INLINE
        props:
          algorithm-expression: bmsql_item_${i_im_id % 2}
      t_bmsql_order_line:
        type: INLINE
        props:
          algorithm-expression: bmsql_order_line_${ol_number % 6}


    tables:
      bmsql_config:
        actualDataNodes: ds_0.bmsql_config
      bmsql_customer:
        actualDataNodes: ds_${0..4}.bmsql_customer
        # tableStrategy:
        #   standard:
        #     shardingColumn: c_id
        #     shardingAlgorithmName: t_bmsql_customer
        databaseStrategy:
          standard:
            shardingAlgorithmName: ds_bmsql_customer_inline
            shardingColumn: c_id
      bmsql_district:
        actualDataNodes: ds_${0..4}.bmsql_district
        databaseStrategy:
          standard:
            shardingAlgorithmName: ds_bmsql_district_inline
            shardingColumn: d_w_id
      bmsql_history:
        actualDataNodes: ds_${0..4}.bmsql_history
        databaseStrategy:
          standard:
            shardingAlgorithmName: ds_bmsql_history_inline
            shardingColumn: h_w_id
      bmsql_item:
        actualDataNodes: ds_${0..4}.bmsql_item_${0..1}
        tableStrategy:
          standard:
            shardingColumn: i_im_id
            shardingAlgorithmName: t_bmsql_item
        databaseStrategy:
          standard:
            shardingAlgorithmName: ds_bmsql_item_inline
            shardingColumn: i_id
      bmsql_new_order:
        actualDataNodes: ds_${0..4}.bmsql_new_order
        databaseStrategy:
          standard:
            shardingAlgorithmName: ds_bmsql_new_order_inline
            shardingColumn: no_w_id
      bmsql_oorder:
        actualDataNodes: ds_${0..4}.bmsql_oorder
        databaseStrategy:
          standard:
            shardingAlgorithmName: ds_bmsql_oorder_inline
            shardingColumn: o_w_id
      bmsql_order_line:
        actualDataNodes: ds_${0..4}.bmsql_order_line_${0..5}
        tableStrategy:
          standard:
            shardingColumn: ol_number
            shardingAlgorithmName: t_bmsql_order_line
        databaseStrategy:
          standard:
            shardingAlgorithmName: ds_bmsql_order_line_inline
            shardingColumn: ol_w_id
      bmsql_stock:
        actualDataNodes: ds_${0..4}.bmsql_stock
        databaseStrategy:
          standard:
            shardingAlgorithmName: ds_bmsql_stock_inline
            shardingColumn: s_w_id
      bmsql_warehouse:
        actualDataNodes: ds_${0..4}.bmsql_warehouse
        databaseStrategy:
          standard:
            shardingAlgorithmName: ds_bmsql_warehouse_inline
            shardingColumn: w_id
</code></pre></div>
<h3 dir="auto">bin/start.sh</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="SERVER_NAME=ShardingSphere-Proxy

cd `dirname $0`
cd ..
DEPLOY_DIR=`pwd`

LOGS_DIR=${DEPLOY_DIR}/logs
if [ ! -d ${LOGS_DIR} ]; then
    mkdir ${LOGS_DIR}
fi

STDOUT_FILE=${LOGS_DIR}/stdout.log
EXT_LIB=${DEPLOY_DIR}/ext-lib

CLASS_PATH=.:${DEPLOY_DIR}/lib/*:${EXT_LIB}/*

JAVA_OPTS=&quot; -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true &quot;

JAVA_MEM_OPTS=&quot; -server -Xmx16g -Xms16g -Xmn8g -Xss1m -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 &quot;

MAIN_CLASS=org.apache.shardingsphere.proxy.Bootstrap

print_usage() {
    echo &quot;usage: start.sh [port] [config_dir]&quot;
    echo &quot;  port: proxy listen port, default is 3307&quot;
    echo &quot;  config_dir: proxy config directory, default is conf&quot;
    exit 0
}

if [ &quot;$1&quot; == &quot;-h&quot; ] || [ &quot;$1&quot; == &quot;--help&quot; ] ; then
    print_usage
fi

echo &quot;Starting the $SERVER_NAME ...&quot;

if [ $# == 0 ]; then
    CLASS_PATH=${DEPLOY_DIR}/conf:${CLASS_PATH}
fi

if [ $# == 1 ]; then
    MAIN_CLASS=${MAIN_CLASS}&quot; &quot;$1
    echo &quot;The port is $1&quot;
    CLASS_PATH=${DEPLOY_DIR}/conf:${CLASS_PATH}
fi

if [ $# == 2 ]; then
    MAIN_CLASS=${MAIN_CLASS}&quot; &quot;$1&quot; &quot;$2
    echo &quot;The port is $1&quot;
    echo &quot;The configuration path is $DEPLOY_DIR/$2&quot;
    CLASS_PATH=${DEPLOY_DIR}/$2:${CLASS_PATH}
fi

echo &quot;The classpath is ${CLASS_PATH}&quot;

nohup java ${JAVA_OPTS} ${JAVA_MEM_OPTS} -classpath ${CLASS_PATH} ${MAIN_CLASS} &gt;&gt; ${STDOUT_FILE} 2&gt;&amp;1 &amp;
sleep 1
echo &quot;Please check the STDOUT file: $STDOUT_FILE&quot;"><pre class="notranslate"><code class="notranslate">SERVER_NAME=ShardingSphere-Proxy

cd `dirname $0`
cd ..
DEPLOY_DIR=`pwd`

LOGS_DIR=${DEPLOY_DIR}/logs
if [ ! -d ${LOGS_DIR} ]; then
    mkdir ${LOGS_DIR}
fi

STDOUT_FILE=${LOGS_DIR}/stdout.log
EXT_LIB=${DEPLOY_DIR}/ext-lib

CLASS_PATH=.:${DEPLOY_DIR}/lib/*:${EXT_LIB}/*

JAVA_OPTS=" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true "

JAVA_MEM_OPTS=" -server -Xmx16g -Xms16g -Xmn8g -Xss1m -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 "

MAIN_CLASS=org.apache.shardingsphere.proxy.Bootstrap

print_usage() {
    echo "usage: start.sh [port] [config_dir]"
    echo "  port: proxy listen port, default is 3307"
    echo "  config_dir: proxy config directory, default is conf"
    exit 0
}

if [ "$1" == "-h" ] || [ "$1" == "--help" ] ; then
    print_usage
fi

echo "Starting the $SERVER_NAME ..."

if [ $# == 0 ]; then
    CLASS_PATH=${DEPLOY_DIR}/conf:${CLASS_PATH}
fi

if [ $# == 1 ]; then
    MAIN_CLASS=${MAIN_CLASS}" "$1
    echo "The port is $1"
    CLASS_PATH=${DEPLOY_DIR}/conf:${CLASS_PATH}
fi

if [ $# == 2 ]; then
    MAIN_CLASS=${MAIN_CLASS}" "$1" "$2
    echo "The port is $1"
    echo "The configuration path is $DEPLOY_DIR/$2"
    CLASS_PATH=${DEPLOY_DIR}/$2:${CLASS_PATH}
fi

echo "The classpath is ${CLASS_PATH}"

nohup java ${JAVA_OPTS} ${JAVA_MEM_OPTS} -classpath ${CLASS_PATH} ${MAIN_CLASS} &gt;&gt; ${STDOUT_FILE} 2&gt;&amp;1 &amp;
sleep 1
echo "Please check the STDOUT file: $STDOUT_FILE"
</code></pre></div>
<h2 dir="auto">About BenchmarkSQL</h2>
<h3 dir="auto">runDatabaseBuild.sh</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="#!/bin/sh

echo $(date &quot;+%Y-%m-%d %H:%M:%S&quot;)

if [ $# -lt 1 ] ; then
    echo &quot;usage: $(basename $0) PROPS [OPT VAL [...]]&quot; &gt;&amp;2
    exit 2
fi

PROPS=&quot;$1&quot;
shift
if [ ! -f &quot;${PROPS}&quot; ] ; then
    echo &quot;${PROPS}: no such file or directory&quot; &gt;&amp;2
    exit 1
fi
DB=&quot;$(grep '^db=' $PROPS | sed -e 's/^db=//')&quot;

BEFORE_LOAD=&quot;tableCreates&quot;
#AFTER_LOAD=&quot;indexCreates foreignKeys extraHistID buildFinish&quot;
AFTER_LOAD=&quot;indexCreates buildFinish&quot;
for step in ${BEFORE_LOAD} ; do
    ./runSQL.sh &quot;${PROPS}&quot; $step
done

./runLoader.sh &quot;${PROPS}&quot; $*

for step in ${AFTER_LOAD} ; do
    ./runSQL.sh &quot;${PROPS}&quot; $step
done

echo $(date &quot;+%Y-%m-%d %H:%M:%S&quot;)

### props.proxy_mysql
db=mysql
driver=com.mysql.jdbc.Driver
conn=jdbc:mysql://IP.10.25:3307/proxy_tpcc?serverTimezone=UTC&amp;useSSL=false&amp;cachePrepStmts=true&amp;prepStmtCacheSize=8000
user=root
password=root

warehouses=200
loadWorkers=200

terminals=200
//To run specified transactions per terminal- runMins must equal zero
runTxnsPerTerminal=0
//To run for specified minutes- runTxnsPerTerminal must equal zero
runMins=10
//Number of total transactions per minute
limitTxnsPerMin=0

//Set to true to run in 4.x compatible mode. Set to false to use the
//entire configured database evenly.
terminalWarehouseFixed=true

//The following five values must add up to 100
//The default percentages of 45, 43, 4, 4 &amp; 4 match the TPC-C spec
newOrderWeight=45
paymentWeight=43
orderStatusWeight=4
deliveryWeight=4
stockLevelWeight=4

// Directory name to create for collecting detailed result data.
// Comment this out to suppress.
resultDirectory=my_result_%tY-%tm-%td_%tH%tM%tS
osCollectorScript=./misc/os_collector_linux.py
osCollectorInterval=1
//osCollectorSSHAddr=user@dbhost
osCollectorDevices=net_eth0 blk_sda"><pre class="notranslate"><code class="notranslate">#!/bin/sh

echo $(date "+%Y-%m-%d %H:%M:%S")

if [ $# -lt 1 ] ; then
    echo "usage: $(basename $0) PROPS [OPT VAL [...]]" &gt;&amp;2
    exit 2
fi

PROPS="$1"
shift
if [ ! -f "${PROPS}" ] ; then
    echo "${PROPS}: no such file or directory" &gt;&amp;2
    exit 1
fi
DB="$(grep '^db=' $PROPS | sed -e 's/^db=//')"

BEFORE_LOAD="tableCreates"
#AFTER_LOAD="indexCreates foreignKeys extraHistID buildFinish"
AFTER_LOAD="indexCreates buildFinish"
for step in ${BEFORE_LOAD} ; do
    ./runSQL.sh "${PROPS}" $step
done

./runLoader.sh "${PROPS}" $*

for step in ${AFTER_LOAD} ; do
    ./runSQL.sh "${PROPS}" $step
done

echo $(date "+%Y-%m-%d %H:%M:%S")

### props.proxy_mysql
db=mysql
driver=com.mysql.jdbc.Driver
conn=jdbc:mysql://IP.10.25:3307/proxy_tpcc?serverTimezone=UTC&amp;useSSL=false&amp;cachePrepStmts=true&amp;prepStmtCacheSize=8000
user=root
password=root

warehouses=200
loadWorkers=200

terminals=200
//To run specified transactions per terminal- runMins must equal zero
runTxnsPerTerminal=0
//To run for specified minutes- runTxnsPerTerminal must equal zero
runMins=10
//Number of total transactions per minute
limitTxnsPerMin=0

//Set to true to run in 4.x compatible mode. Set to false to use the
//entire configured database evenly.
terminalWarehouseFixed=true

//The following five values must add up to 100
//The default percentages of 45, 43, 4, 4 &amp; 4 match the TPC-C spec
newOrderWeight=45
paymentWeight=43
orderStatusWeight=4
deliveryWeight=4
stockLevelWeight=4

// Directory name to create for collecting detailed result data.
// Comment this out to suppress.
resultDirectory=my_result_%tY-%tm-%td_%tH%tM%tS
osCollectorScript=./misc/os_collector_linux.py
osCollectorInterval=1
//osCollectorSSHAddr=user@dbhost
osCollectorDevices=net_eth0 blk_sda
</code></pre></div>
<h2 dir="auto">About MySQL</h2>
<h3 dir="auto">my.cnf</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[mysqld]
server_id=13306
port =3306
basedir=/usr/local/mysql5.7
datadir=/data/mysql/mysql3306/data
log-error=/data/mysql/mysql3306/data/mysql.err
log_bin=/data/mysql/mysql3306/data/mysql-bin
gtid-mode=on
enforce-gtid-consistency=true
log-slave-updates=1
character_set_server = utf8mb4
pid-file=/data/mysql/mysql3306/data/mysql.pid
socket=/tmp/mysql3306.sock
max_connections=50000
expire_logs_days=1

innodb_buffer_pool_size=8000000000
###
innodb-log-file-size=2000000000
innodb-log-files-in-group=3
innodb-flush-log-at-trx-commit=0
innodb-change-buffer-max-size=40
back_log=900
#innodb_io_capacity
#innodb_io_capacity_max
innodb_max_dirty_pages_pct=75
innodb_open_files=20480
innodb_buffer_pool_instances=8
innodb_page_cleaners=8
innodb_purge_threads=2
innodb_read_io_threads=8
innodb_write_io_threads=8
table_open_cache=102400
#binlog_expire_logs_seconds=43200
binlog_format=mixed
log_timestamps=system
thread_cache_size=16384"><pre class="notranslate"><code class="notranslate">[mysqld]
server_id=13306
port =3306
basedir=/usr/local/mysql5.7
datadir=/data/mysql/mysql3306/data
log-error=/data/mysql/mysql3306/data/mysql.err
log_bin=/data/mysql/mysql3306/data/mysql-bin
gtid-mode=on
enforce-gtid-consistency=true
log-slave-updates=1
character_set_server = utf8mb4
pid-file=/data/mysql/mysql3306/data/mysql.pid
socket=/tmp/mysql3306.sock
max_connections=50000
expire_logs_days=1

innodb_buffer_pool_size=8000000000
###
innodb-log-file-size=2000000000
innodb-log-files-in-group=3
innodb-flush-log-at-trx-commit=0
innodb-change-buffer-max-size=40
back_log=900
#innodb_io_capacity
#innodb_io_capacity_max
innodb_max_dirty_pages_pct=75
innodb_open_files=20480
innodb_buffer_pool_instances=8
innodb_page_cleaners=8
innodb_purge_threads=2
innodb_read_io_threads=8
innodb_write_io_threads=8
table_open_cache=102400
#binlog_expire_logs_seconds=43200
binlog_format=mixed
log_timestamps=system
thread_cache_size=16384
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="### ds 准备
create database tpcc0 ;
create database tpcc1 ;
create database tpcc2 ;
create database tpcc3 ;
create database tpcc4 ;"><pre class="notranslate"><code class="notranslate">### ds 准备
create database tpcc0 ;
create database tpcc1 ;
create database tpcc2 ;
create database tpcc3 ;
create database tpcc4 ;
</code></pre></div>
<h2 dir="auto">BenchmarkSQL do</h2>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="./runDatabaseDestroy.sh props.proxy_mysql
time ./runDatabaseBuild.sh  props.proxy_mysql &gt; 200test &amp;"><pre class="notranslate"><code class="notranslate">./runDatabaseDestroy.sh props.proxy_mysql
time ./runDatabaseBuild.sh  props.proxy_mysql &gt; 200test &amp;
</code></pre></div>
<p dir="auto">Please answer these questions before submitting your issue. Thanks!</p>
<h3 dir="auto">Which version of Sharding-Jdbc do you using?</h3>
<p dir="auto">1.4.2</p>
<h3 dir="auto">Expected behavior</h3>
<p dir="auto">分页查询，select * from t_order limit 2,2  路由多个分片，只有一个分片有数据，查询4条记录</p>
<h3 dir="auto">Actual behavior</h3>
<p dir="auto">应该只返回2条记录</p>
<h3 dir="auto">Steps to reproduce the behavior</h3>
<p dir="auto">sharding-jdbc-example-mybatis这个demo工程中，增加测试类<br>
`<br>
package com.dangdang.ddframe.rdb.sharding.example.jdbc;<br>
import com.dangdang.ddframe.rdb.sharding.example.jdbc.entity.Order;<br>
import com.dangdang.ddframe.rdb.sharding.example.jdbc.repository.OrderRepository;<br>
import org.springframework.context.ApplicationContext;<br>
import org.springframework.context.support.ClassPathXmlApplicationContext;<br>
import java.util.List;</p>
<p dir="auto">public class Test {<br>
public static void main(final String[] args) {<br>
ApplicationContext applicationContext = new ClassPathXmlApplicationContext("META-INF/mybatisContext.xml");<br>
OrderRepository orderRepository = applicationContext.getBean(OrderRepository.class);<br>
List ls = orderRepository.selectAll();<br>
System.out.println(ls);<br>
}<br>
}</p>
<p dir="auto">`</p>
<p dir="auto">修改OrderMapper.xml最后一个查询，增加limit<br>
`</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;select id=&quot;selectAll&quot; resultMap=&quot;baseResultMap&quot;&gt;
    SELECT
    &lt;include refid=&quot;baseColumnList&quot;/&gt;
    FROM `t_order` limit 2,2
&lt;/select&gt;"><pre class="notranslate"><code class="notranslate">&lt;select id="selectAll" resultMap="baseResultMap"&gt;
    SELECT
    &lt;include refid="baseColumnList"/&gt;
    FROM `t_order` limit 2,2
&lt;/select&gt;
</code></pre></div>
<p dir="auto"><code class="notranslate">修改数据库数据：</code><br>
delete  from ds_0.t_order_0;<br>
delete  from ds_0.t_order_1;<br>
delete  from ds_1.t_order_0;<br>
delete  from ds_1.t_order_1;</p>
<p dir="auto">INSERT INTO <code class="notranslate">ds_0</code>.<code class="notranslate">t_order_0</code> VALUES (1000, 10, 'INIT');<br>
INSERT INTO <code class="notranslate">ds_0</code>.<code class="notranslate">t_order_0</code> VALUES (1002, 10, 'INIT');<br>
INSERT INTO <code class="notranslate">ds_0</code>.<code class="notranslate">t_order_0</code> VALUES (1004, 10, 'INIT');<br>
INSERT INTO <code class="notranslate">ds_0</code>.<code class="notranslate">t_order_0</code> VALUES (1006, 10, 'INIT');<br>
INSERT INTO <code class="notranslate">ds_0</code>.<code class="notranslate">t_order_0</code> VALUES (1008, 10, 'INIT');<br>
`</p>
<p dir="auto">执行打印结果有4条记录：<br>
[order_id: 1000, user_id: 10, status: INIT, order_id: 1002, user_id: 10, status: INIT, order_id: 1004, user_id: 10, status: INIT, order_id: 1006, user_id: 10, status: INIT]</p>
<p dir="auto">调试代码发现，shardingJDBC在包装结果集时，根据mergeContext判断是不是要聚合，ResultSetFactory.getResultSet方法中<br>
ShardingResultSets shardingResultSets = new ShardingResultSets(resultSets);<br>
传入的resultSets有4个rs，获取到的shardingResultSets 只有一个，因为只有一个rs有数据，<br>
ShardingResultSets.filterResultSets方法会过滤掉没有记录的rs<br>
`</p>
<p dir="auto">private List filterResultSets(final List resultSets) throws SQLException {<br>
List result = new ArrayList&lt;&gt;(resultSets.size());<br>
for (ResultSet each : resultSets) {<br>
if (each.next()) {<br>
result.add(new WrapperResultSet(each));<br>
}<br>
}<br>
return result;<br>
}<br>
`</p>
<p dir="auto">这样的话在shardingResultSets.getType()返回的是SINGLE<br>
`</p>
<p dir="auto">switch (shardingResultSets.getType()) {<br>
case EMPTY:<br>
return buildEmpty(resultSets);<br>
case SINGLE:<br>
return buildSingle(shardingResultSets);<br>
case MULTIPLE:<br>
return buildMultiple(shardingResultSets, mergeContext);<br>
default:<br>
throw new UnsupportedOperationException(shardingResultSets.getType().toString());<br>
}<br>
`<br>
这样就不会去做合并结果集操作了</p>
<h3 dir="auto">Please provide the reproduce example codes (such as github link) if possible.</h3>