获取配置的shardingsphere分库分表的数据库链接,并连接每个分库分表执行数据归档逻辑

前言

随着分库分表的数据量越来越大,一些无用的数据,比如取消的订单需要删除以减少数据库成本(特殊场景,95%的订单都是已取消的无效订单)。但是shardingsphere自带的查询需要分片键才能出查询对应的分库分表。做数据归档删除的时候没有分片键,直接查询会查询所有的分库分表,性能较差。

shardingsphere配置信息

spring:
  shardingsphere:
    # 参数配置,显示sql
    props:
      sql.show: true
    # 配置数据源
    datasource:
      names: ds1,ds2,ds3,ds4,ds5,ds6,ds7,ds8,ds9,ds10,ds11,ds12,ds13,ds14,ds15,ds16
      ds1:
        type: com.alibaba.druid.pool.DruidDataSource
        driver-class-name: com.mysql.jdbc.Driver
        url: jdbc:mysql://10.0.2.4:63306/order_1?useUnicode=true&characterEncoding=utf-8&useSSL=false
        username: xxx
        password: xxxxxxx
        druid:
          initialSize: 30
          maxActive: 100
          minIdle: 5
          maxWait: 1000
          minEvictableIdleTimeMillis: 300000
          useGlobalDataSourceStat: true
          timeBetweenEvictionRunsMillis: 60000
          validationQuery: select 'x'
          testOnBorrow: true
          testOnReturn: true
          testWhileIdle: true
      ds2:
        type: com.alibaba.druid.pool.DruidDataSource
        driver-class-name: com.mysql.jdbc.Driver
        url: jdbc:mysql://10.0.2.4:63306/order_2?useUnicode=true&characterEncoding=utf-8&useSSL=false
        username: xxx
        password: xxxxxxx
        druid:
          initialSize: 30
          maxActive: 100
          minIdle: 5
          maxWait: 1000
          minEvictableIdleTimeMillis: 300000
          useGlobalDataSourceStat: true
          timeBetweenEvictionRunsMillis: 60000
          validationQuery: select 'x'
          testOnBorrow: true
          testOnReturn: true
          testWhileIdle: true
      ds3:
        type: com.alibaba.druid.pool.DruidDataSource
        driver-class-name: com.mysql.jdbc.Driver
        url: jdbc:mysql://10.0.2.4:63306/order_3?useUnicode=true&characterEncoding=utf-8&useSSL=false
        username: xxx
        password: xxxxxxx
        druid:
          initialSize: 30
          maxActive: 100
          minIdle: 5
          maxWait: 1000
          minEvictableIdleTimeMillis: 300000
          useGlobalDataSourceStat: true
          timeBetweenEvictionRunsMillis: 60000
          validationQuery: select 'x'
          testOnBorrow: true
          testOnReturn: true
          testWhileIdle: true
      ds4:
        type: com.alibaba.druid.pool.DruidDataSource
        driver-class-name: com.mysql.jdbc.Driver
        url: jdbc:mysql://10.0.2.4:63306/order_4?useUnicode=true&characterEncoding=utf-8&useSSL=false
        username: xxx
        password: xxxxxxx
        druid:
          initialSize: 30
          maxActive: 100
          minIdle: 5
          maxWait: 1000
          minEvictableIdleTimeMillis: 300000
          useGlobalDataSourceStat: true
          timeBetweenEvictionRunsMillis: 60000
          validationQuery: select 'x'
          testOnBorrow: true
          testOnReturn: true
          testWhileIdle: true
      ds5:
        type: com.alibaba.druid.pool.DruidDataSource
        driver-class-name: com.mysql.jdbc.Driver
        url: jdbc:mysql://10.0.2.4:63306/order_5?useUnicode=true&characterEncoding=utf-8&useSSL=false
        username: xxx
        password: xxxxxxx
        druid:
          initialSize: 30
          maxActive: 100
          minIdle: 5
          maxWait: 1000
          minEvictableIdleTimeMillis: 300000
          useGlobalDataSourceStat: true
          timeBetweenEvictionRunsMillis: 60000
          validationQuery: select 'x'
          testOnBorrow: true
          testOnReturn: true
          testWhileIdle: true
      ds6:
        type: com.alibaba.druid.pool.DruidDataSource
        driver-class-name: com.mysql.jdbc.Driver
        url: jdbc:mysql://10.0.2.4:63306/order_6?useUnicode=true&characterEncoding=utf-8&useSSL=false
        username: xxx
        password: xxxxxxx
        druid:
          initialSize: 30
          maxActive: 100
          minIdle: 5
          maxWait: 1000
          minEvictableIdleTimeMillis: 300000
          useGlo
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值