Ruffianjiang commented on issue #60634:
URL: https://github.com/apache/doris/issues/60634#issuecomment-3989504759

   以下是复现的主要代码 @morningman 
   1. mybatis-plus 3.5.9
   2. spring-boot 3.5.11
   3. mysql-connector-j 9.6.0
   4. doris doris-3.1.4-rc02-7f5ba43de6
   
   表现结果:
   1. 第一、二个url查询正常,**第三个查不到数据**
   2. Group Commit的性能是一二三,越来越强
   3. 
第一个是mysql的默认参数,第三个是doris的默认参数**useServerPrepStmts=true**,第二个把doris默认参数改为**useServerPrepStmts=false&cacheResultSetMetadata=true**
   
   建表
   ```sql
   CREATE TABLE IF NOT EXISTS `t_user` (
       `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '主键ID',
       `username` VARCHAR(64) NOT NULL COMMENT '用户名',
       `password` VARCHAR(128) NOT NULL COMMENT '密码',
       `email` VARCHAR(128) COMMENT '邮箱',
       `phone` VARCHAR(20) COMMENT '手机号',
       `create_time` DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
       `update_time` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE 
CURRENT_TIMESTAMP COMMENT '更新时间'
   ) ENGINE=OLAP
   UNIQUE KEY(`id`)
   DISTRIBUTED BY HASH(`id`) BUCKETS 3
   PROPERTIES (
       "replication_num" = "3"
   );
   ```
   初始化sql
   ```sql
   INSERT INTO `t_user` (`username`, `password`, `email`, `phone`, 
`create_time`, `update_time`) VALUES
   ('zhangsan', 'e10adc3949ba59abbe56e057f20f883e', '[email protected]', 
'13800138001', '2026-03-03 10:00:00', '2026-03-03 10:00:00'),
   ('lisi', 'e10adc3949ba59abbe56e057f20f883e', '[email protected]', 
'13800138002', '2026-03-03 10:00:00', '2026-03-03 10:00:00'),
   ('wangwu', 'e10adc3949ba59abbe56e057f20f883e', '[email protected]', 
'13800138003', '2026-03-03 10:00:00', '2026-03-03 10:00:00'),
   ('zhaoliu', 'e10adc3949ba59abbe56e057f20f883e', '[email protected]', 
'13800138004', '2026-03-03 10:00:00', '2026-03-03 10:00:00'),
   ('sunqi', 'e10adc3949ba59abbe56e057f20f883e', '[email protected]', 
'13800138005', '2026-03-03 10:00:00', '2026-03-03 10:00:00'),
   ('zhouba', 'e10adc3949ba59abbe56e057f20f883e', '[email protected]', 
'13800138006', '2026-03-03 10:00:00', '2026-03-03 10:00:00'),
   ('wujiu', 'e10adc3949ba59abbe56e057f20f883e', '[email protected]', 
'13800138007', '2026-03-03 10:00:00', '2026-03-03 10:00:00'),
   ('zhengshi', 'e10adc3949ba59abbe56e057f20f883e', '[email protected]', 
'13800138008', '2026-03-03 10:00:00', '2026-03-03 10:00:00'),
   ('admin', 'e10adc3949ba59abbe56e057f20f883e', '[email protected]', 
'13800138009', '2026-03-03 10:00:00', '2026-03-03 10:00:00'),
   ('test', 'e10adc3949ba59abbe56e057f20f883e', '[email protected]', 
'13800138010', '2026-03-03 10:00:00', '2026-03-03 10:00:00');
   ```
   
   pom.xml
   ```xml
   <?xml version="1.0" encoding="UTF-8"?>
   <project xmlns="http://maven.apache.org/POM/4.0.0";
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
            xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
https://maven.apache.org/xsd/maven-4.0.0.xsd";>
       <modelVersion>4.0.0</modelVersion>
   
       <parent>
           <groupId>org.springframework.boot</groupId>
           <artifactId>spring-boot-starter-parent</artifactId>
           <version>3.5.11</version>
           <relativePath/>
       </parent>
   
       <groupId>com.xxx</groupId>
       <artifactId>doris-jdbc</artifactId>
       <version>1.0.0</version>
       <name>doris-jdbc</name>
       <description>doris-jdbc</description>
   
       <properties>
           <java.version>21</java.version>
           <mybatis-plus.version>3.5.9</mybatis-plus.version>
       </properties>
   
       <dependencies>
           <dependency>
               <groupId>org.springframework.boot</groupId>
               <artifactId>spring-boot-starter-web</artifactId>
           </dependency>
   
           <dependency>
               <groupId>org.springframework.boot</groupId>
               <artifactId>spring-boot-starter-jdbc</artifactId>
           </dependency>
   
           <dependency>
               <groupId>com.baomidou</groupId>
               <artifactId>mybatis-plus-spring-boot3-starter</artifactId>
               <version>${mybatis-plus.version}</version>
           </dependency>
   
           <dependency>
               <groupId>com.mysql</groupId>
               <artifactId>mysql-connector-j</artifactId>
               <scope>runtime</scope>
           </dependency>
   
           <dependency>
               <groupId>org.projectlombok</groupId>
               <artifactId>lombok</artifactId>
               <optional>true</optional>
           </dependency>
   
           <dependency>
               <groupId>org.springframework.boot</groupId>
               <artifactId>spring-boot-starter-test</artifactId>
               <scope>test</scope>
           </dependency>
       </dependencies>
   
       <build>
           <plugins>
               <plugin>
                   <groupId>org.springframework.boot</groupId>
                   <artifactId>spring-boot-maven-plugin</artifactId>
                   <configuration>
                       <excludes>
                           <exclude>
                               <groupId>org.projectlombok</groupId>
                               <artifactId>lombok</artifactId>
                           </exclude>
                       </excludes>
                   </configuration>
               </plugin>
           </plugins>
       </build>
   
   </project>
   ```
   
   
   application.yml
   ```yaml
   spring:
     application:
       name: doris-jdbc
     datasource:
       driver-class-name: com.mysql.cj.jdbc.Driver
   #    url: 
jdbc:mysql://xxx:9030/demo?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true&sessionVariables=group_commit=async_mode
   #    url: 
jdbc:mysql://xxx:9030/demo?useServerPrepStmts=false&cacheResultSetMetadata=true&useLocalSessionState=true&rewriteBatchedStatements=true&cachePrepStmts=true&prepStmtCacheSqlLimit=99999&prepStmtCacheSize=50&sessionVariables=group_commit=async_mode
       url: 
jdbc:mysql://xxx:9030/demo?useServerPrepStmts=true&useLocalSessionState=true&rewriteBatchedStatements=true&cachePrepStmts=true&prepStmtCacheSqlLimit=99999&prepStmtCacheSize=50&sessionVariables=group_commit=async_mode
       username: root
       password: xxx
   
   server:
     port: 8080
   
   mybatis-plus:
     configuration:
       map-underscore-to-camel-case: true
       log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
     global-config:
       db-config:
         id-type: auto
         logic-delete-field: deleted
         logic-delete-value: 1
         logic-not-delete-value: 0
     mapper-locations: classpath:mapper/*.xml
   ```
   User
   ```java
   @Data
   @TableName("t_user")
   public class User {
   
       /**
        * 主键ID
        */
       @TableId(type = IdType.AUTO)
       private Long id;
   
       /**
        * 用户名
        */
       private String username;
   
       /**
        * 密码
        */
       private String password;
   
       /**
        * 邮箱
        */
       private String email;
   
       /**
        * 手机号
        */
       private String phone;
   
       /**
        * 创建时间
        */
       private LocalDateTime createTime;
   
       /**
        * 更新时间
        */
       private LocalDateTime updateTime;
   }
   ```
   UserMapper
   ```java
   @Mapper
   public interface UserMapper extends BaseMapper<User> {}
   ```
   UserService
   ```java
   public interface UserService extends IService<User> {}
   ```
   UserServiceImpl
   ```java
   @Service
   public class UserServiceImpl extends ServiceImpl<UserMapper, User> 
implements UserService {}
   ```
   UseServiceQueryTest
   ```java
   @SpringBootTest
   @Slf4j
   class UseServiceQueryTest {
   
       @Autowired
       private UserService userService;
   
       @Test
       @DisplayName("测试查询用户")
       void testGetUserById() {
           User foundUser = userService.getById(1L);
           assertNotNull(foundUser, "查询到的用户不应该为空");
           log.info("foundUser username: {}", foundUser.getUsername());
           List<User> users = userService.list(new Page<>(1, 10));
           log.info("users size: {}", users.size());
       }
   }
   ```
   
   


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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to