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 2021/02/18 01:50:54 UTC

[GitHub] [shardingsphere] jmbkeyes opened a new issue #9420: Why are there 4 SQL queries?

jmbkeyes opened a new issue #9420:
URL: https://github.com/apache/shardingsphere/issues/9420


   ## Question
   There's a table, with month(yyyyMM)as sharding key, the springboot config file as below
   `server:
     port: 9090
   spring:
     shardingsphere:
       datasource:
         names: bocaicheckin${2019..2020}
         bocaicheckin2019:
           type: com.zaxxer.hikari.HikariDataSource
           driver-class-name: com.mysql.jdbc.Driver
           jdbc-url: jdbc:mysql://10.0.0.5:3306/bocai_checkin2019
           username: root
           password: jmbkeyes
         bocaicheckin2020:
           type: com.zaxxer.hikari.HikariDataSource
           driver-class-name: com.mysql.jdbc.Driver
           jdbc-url: jdbc:mysql://10.0.0.5:3306/bocai_checkin2020
           username: root
           password: jmbkeyes
   
       sharding:
         tables:
           trainee_checkin_checkout:
             actual-data-nodes: bocaicheckin${2019..2020}.trainee_checkin_checkout_${1..12}
             database-strategy:
               inline:
                 sharding-column: month
                 algorithm-expression: bocaicheckin${(month / 100) as int}
             table-strategy:
               inline:
                 sharding-column: month
                 algorithm-expression: trainee_checkin_checkout_${month % 100}
       props:
         sql.show: true
   
   `
   
   
   **For English only**, other languages will not accept.
   
   Before asking a question, make sure you have:
   
   - Googled your question.
   - Searched open and closed [GitHub issues](https://github.com/apache/shardingsphere/issues).
   - Read documentation: [ShardingSphere Doc](https://shardingsphere.apache.org/document/current/en/overview).
   
   Please pay attention on issues you submitted, because we maybe need more details. 
   If no response anymore and we cannot reproduce it on current information, we will **close it**.
   


----------------------------------------------------------------
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



[GitHub] [shardingsphere] devfat commented on issue #9420: Why are there 4 actual sql queries?

Posted by GitBox <gi...@apache.org>.
devfat commented on issue #9420:
URL: https://github.com/apache/shardingsphere/issues/9420#issuecomment-781096065


   it is that your table-strategy is according to your `month` column in your configuration. The month list in query is `202001,202002,201901`,  and will map to your table of `trainee_checkin_checkout_1` and `trainee_checkin_checkout_2`


----------------------------------------------------------------
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



[GitHub] [shardingsphere] jmbkeyes commented on issue #9420: Why are there 4 actual sql queries?

Posted by GitBox <gi...@apache.org>.
jmbkeyes commented on issue #9420:
URL: https://github.com/apache/shardingsphere/issues/9420#issuecomment-781226245


   @devfat 
   Yes, table-strategy is according to month column. Hmm.., if there're M databases, and N months(different month index of year) in query sql, and will perform M*N actual sql query? Any way to avoid this?
   


----------------------------------------------------------------
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



[GitHub] [shardingsphere] jmbkeyes closed issue #9420: Why are there 4 actual sql queries?

Posted by GitBox <gi...@apache.org>.
jmbkeyes closed issue #9420:
URL: https://github.com/apache/shardingsphere/issues/9420


   


----------------------------------------------------------------
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



[GitHub] [shardingsphere] jmbkeyes commented on issue #9420: Why are there 4 actual sql queries?

Posted by GitBox <gi...@apache.org>.
jmbkeyes commented on issue #9420:
URL: https://github.com/apache/shardingsphere/issues/9420#issuecomment-781235654


   Hmm, So i means that  it'll do M(different year count) * N(different month index count) actual sql queries.  Is there any way to do some optimization?


----------------------------------------------------------------
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



[GitHub] [shardingsphere] jmbkeyes removed a comment on issue #9420: Why are there 4 actual sql queries?

Posted by GitBox <gi...@apache.org>.
jmbkeyes removed a comment on issue #9420:
URL: https://github.com/apache/shardingsphere/issues/9420#issuecomment-781226245


   @devfat 
   Yes, table-strategy is according to month column. Hmm.., if there're M databases, and N months(different month index of year) in query sql, and will perform M*N actual sql query? Any way to avoid this?
   


----------------------------------------------------------------
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