You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/01/12 13:32:26 UTC

[GitHub] [incubator-shardingsphere] kimmking commented on issue #3929: How to config rules for range query in sharding proxy without any coding ?

kimmking commented on issue #3929: How to config rules  for range query in sharding proxy without any coding ?
URL: https://github.com/apache/incubator-shardingsphere/issues/3929#issuecomment-573415748
 
 
   I found this error is puzzle for me in this case in past 3 weeks.
   
   There is a sharding table named 'test' with 4 actual tables with sharding key is 'id' column, then we will try proxy with:
   - 1.select * from test
   - 2.select * from test where id=102
   - 3.select * from test where id>102
   - 4.select * from test where id>102 and id<104
   - 5.select * from test where id<>102
   - 6.select * from test where id!=102
   - 7.select * from test where id between 102 and 104
   - 8.select * from test where id in (102, 104)
   - 9.select * from test where id not in (102, 104)
   - 10.select * from test where id>102 or id<102
   
   Executing these No. 3\4\7\10 SQL will occur the same exception:
   `
   [2020-01-12 14:01:13] [C1000][10002] 2Unknown exception: [Inline strategy cannot support range sharding.]
   `
   
   When I read `incubator-shardingsphere/sharding-core/sharding-core-common/src/main/java/org/apache/shardingsphere/core/strategy/route/inline/InlineShardingStrategy.java`, we can learn InlineShardingStrategy isn't support Range query: 
   `
   Preconditions.checkState(shardingValue instanceof ListRouteValue, "Inline strategy cannot support range sharding.");  
   `
   
   But the puzzle is: the No.10 SQL(can't executed) is equals with the No.5(executed correctly), the I wanna ask why and how to support range query in sharding strategy?
   
   Aside from performance considerations, we can find the most effective way to directly support this feature by broadcasting the whole Range query to all sharding db/tables,just like  ‘<>’ operator.
   
   
   Then we can let it work well and optimized later,we can insert here one line to broadcasting sql:
   `
   if (shardingValue instanceof RangeRouteValue) {
               return availableTargetNames;
           }
   `
   
   Then the No.3\4\7\10 SQL will be executed correctly.
   
   Related PR: https://github.com/apache/incubator-shardingsphere/pull/3945
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services