kimmking commented on issue #7201:
URL: https://github.com/apache/shardingsphere/issues/7201#issuecomment-686965948


   Config master-slave rules and test.
   ```
   schemaName: testms
   
   dataSources:
     db:
       url: jdbc:mysql://127.0.0.1:3306/db?serverTimezone=UTC&useSSL=false
       username: root
       password:
       connectionTimeoutMilliseconds: 30000
       idleTimeoutMilliseconds: 60000
       maxLifetimeMilliseconds: 1800000
       maxPoolSize: 50
     db0:
       url: jdbc:mysql://127.0.0.1:3306/db0?serverTimezone=UTC&useSSL=false
       username: root
       password:
       connectionTimeoutMilliseconds: 30000
       idleTimeoutMilliseconds: 60000
       maxLifetimeMilliseconds: 1800000
       maxPoolSize: 50
     db1:
       url: jdbc:mysql://127.0.0.1:3306/db1?serverTimezone=UTC&useSSL=false
       username: root
       password:
       connectionTimeoutMilliseconds: 30000
       idleTimeoutMilliseconds: 60000
       maxLifetimeMilliseconds: 1800000
       maxPoolSize: 50
   rules:
   - !MASTER_SLAVE
     dataSources:
       ms_ds:
         name: ms_ds
         masterDataSourceName: db
         slaveDataSourceNames:
           - db0
           - db1
   ```
   
   the test case:
   ```
   mysql> select * from test;
   +----+------+---------------------+
   | id | name | created             |
   +----+------+---------------------+
   |  1 | KK01 | 2020-09-04 15:15:40 |
   |  2 | KK02 | 2020-09-04 15:15:40 |
   |  3 | KK03 | 2020-09-04 15:15:40 |
   |  4 | KK04 | 2020-09-04 15:15:40 |
   |  5 | KK05 | 2020-09-04 15:15:40 |
   |  6 | KK06 | 2020-09-04 15:15:40 |
   |  7 | KK07 | 2020-09-04 15:15:41 |
   |  8 | KK08 | 2020-09-04 15:15:41 |
   +----+------+---------------------+
   8 rows in set (0.01 sec)
   
   mysql> select distinct id,name from test;
   +----+------+
   | id | name |
   +----+------+
   |  1 | KK01 |
   |  2 | KK02 |
   |  3 | KK03 |
   |  4 | KK04 |
   |  5 | KK05 |
   |  6 | KK06 |
   |  7 | KK07 |
   |  8 | KK08 |
   +----+------+
   8 rows in set (0.02 sec)
   
   mysql> select * from test order by id;
   +----+------+---------------------+
   | id | name | created             |
   +----+------+---------------------+
   |  1 | KK01 | 2020-09-04 15:15:40 |
   |  2 | KK02 | 2020-09-04 15:15:40 |
   |  3 | KK03 | 2020-09-04 15:15:40 |
   |  4 | KK04 | 2020-09-04 15:15:40 |
   |  5 | KK05 | 2020-09-04 15:15:40 |
   |  6 | KK06 | 2020-09-04 15:15:40 |
   |  7 | KK07 | 2020-09-04 15:15:41 |
   |  8 | KK08 | 2020-09-04 15:15:41 |
   +----+------+---------------------+
   8 rows in set (0.01 sec)
   
   mysql> select sum(id) from test;
   +---------+
   | sum(id) |
   +---------+
   |      36 |
   +---------+
   1 row in set (0.01 sec)
   
   mysql> select avg(id) from test;
   +---------+
   | avg(id) |
   +---------+
   |  4.5000 |
   +---------+
   1 row in set (0.00 sec)
   
   mysql> select avg(distinct id) from test;
   +------------------+
   | avg(distinct id) |
   +------------------+
   |           4.5000 |
   +------------------+
   1 row in set (0.01 sec)
   ```
   
   It's the same with sharding rules, except avg+distinct. 
   


----------------------------------------------------------------
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:
[email protected]


Reply via email to