springboot + mybatis-plus + shardingsphere 启动项目非常慢

开源之夏第三届火热来袭,高校学生参与赢万元奖金!>>>

springboot + mybatis-plus + shardingsphere 启动项目非常慢

springboot2.4.5

mybatis-plus3.4.1

shardingsphere-jdbc-core-spring-boot-starter5.1.2

单库,20张表,其中1张表分表

11代I7, 16G内存

未分表前启动很快,10s左右,分表后平均时间6分多钟

配置:

spring:
  shardingsphere:
    datasource:
      ds:
        driver-class-name: com.mysql.cj.jdbc.Driver
        jdbc-url: jdbc:mysql://localhost:3306/test?useSSL=false&useUnicode=true&characterEncoding=utf-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true
        password: 123456
        type: com.zaxxer.hikari.HikariDataSource
        username: root
        validation-timeout: 5000
        connection-timeout: 30000
        max-lifetime: 1800000
        maximum-pool-size: 20
        minimum-idle: 5
        idle-timeout: 600000
        auto-commit: true
        connection-test-query: SELECT 1
        pool-name: ${spring.application.name}-ds
      names: ds
    mode:
      type: Memory
    rules:
      sharding:
        key-generators:
          snowflake:
            type: SNOWFLAKE
        sharding-algorithms:
          local-date-time-inline:
            props:
              strategy: standard
              algorithmClassName: com.test.sharding.CustomLocalDateTimeStrategyShardingAlgorithm
            type: CLASS_BASED
        tables:
          solar_forward_combiner_box_data_his:
            actual-data-nodes: ds.test_bigdata_his_202$->{201..912}
            key-generate-strategy:
              column: id
              key-generator-name: snowflake
            table-strategy:
              standard:
                sharding-algorithm-name: local-date-time-inline
                sharding-column: data_time
    props:
      # \u662F\u5426\u663E\u793Asql
      sql-show: true
      max:
        connections:
          size:
            per:
              # 开启内存模式
              query: 50

回答

日志加级别调debug,看一下主要哪个地方长耗时了