huomengbo opened a new issue, #9949:
URL: https://github.com/apache/seatunnel/issues/9949

   ### Search before asking
   
   - [x] I had searched in the 
[issues](https://github.com/apache/seatunnel/issues?q=is%3Aissue+label%3A%22bug%22)
 and found no similar issues.
   
   
   ### What happened
   
   同步历史数据的时候,未配置snapshotSplitColumn,会自动获取到coin_type字段作为切分列,因为数据量比较大,没有走索引,导致慢sql
   
   表结构
   CREATE TABLE `user` (
     `addr_id` bigint NOT NULL AUTO_INCREMENT COMMENT '地址',
     `user_id` bigint NOT NULL DEFAULT '0' COMMENT '用户id',
     `address` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci 
NOT NULL COMMENT '地址2',
     `type` int NOT NULL DEFAULT '3' COMMENT '类型',
     `created_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
     `modify_date` timestamp NULL DEFAULT NULL COMMENT '修改时间',
     PRIMARY KEY (`addr_id`),
     UNIQUE KEY `address` (`address`,`coin_type`)
   ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3
   
   
原因:在自动选择的时候,获取到了唯一索引,但是int的优先级比bigint和string的优先级高,导致选择了coin_type,但是联合索引,不指定第一个字段,第二个字段是无法使用索引的,下面源码地方,应该取消for循环,只能选择第一个字段作为切分列
   
   源码:AbstractJdbcSourceChunkSplitter
   
   <img width="1856" height="1610" alt="Image" 
src="https://github.com/user-attachments/assets/f8a49369-bf5a-4bfe-aa4c-9a954a824f49";
 />
   
   ### SeaTunnel Version
   
   2.3.10
   
   ### SeaTunnel Config
   
   ```conf
   -
   ```
   
   ### Running Command
   
   ```shell
   -
   ```
   
   ### Error Exception
   
   ```log
   扫描数据库慢sql
   ```
   
   ### Zeta or Flink or Spark Version
   
   _No response_
   
   ### Java or Scala Version
   
   jdk8
   
   ### Screenshots
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


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

Reply via email to