matrixorigin / matrixorigin/matrixone

perf: big-data insert into select performance optimization.

Open
#26,133 1 comment 0 reactions 1 assignee Claimed by @aunjgr View on GitHub
kind/performance severity/s0
Dominant language
Go
Stars
1.9k
Forks
311
Avg merge
1d 3h
Merged PRs (30d)
768

Description

## 问题描述

big-data 测试中的 `03 PK Index Insert` 测试性能需要优化,现在需要1 小时 8 分钟;
`04 Com PK Index Insert`测试性能需要优化,现在需要1 小时 15分钟;
`07 Write Insert`测试性能需要优化,现在需要1 小时 8分钟;

## 测试结果

**Job**: [Insert 10Y / 03 PK Index Insert](https://github.com/matrixorigin/mo-nightly-regression/actions/runs/29977409547/job/89130417745)

**执行时间**: 2026-07-23 06:41:01Z -> 07:49:32Z (68 分钟)

**SQL**:
```sql
insert into big_data_test.table_with_pk_index_for_insert_1B(id,col1,col2,col3,col4,col5,col6,col7,col8,col9,col10,col11,col12,col13,col14,col15,col16,col17,col18,col19,col20,col21,col22,col23,col24,col25)
select * from big_data_test.table_with_pk_for_load_1B
where col4 != -7508478199581380391;

insert into big_data_test.table_with_com_pk_index_for_insert_1B(id,col1,col2,col3,col4,col5,col6,col7,col8,col9,col10,col11,col12,col13,col14,col15,col16,col17,col18,col19,col20,col21,col22,col23,col24,col25) select * from big_data_test.table_with_pk_for_load_1B where col4 != -7508478199581380391;

insert into big_data_test.table_with_pk_index_for_write_1B select * from big_data_test.table_with_pk_for_load_1B where col4 != -7508478199581380391;
```

**执行耗时**: 4089296.49ms (68 分钟)

## 环境

- **Branch**: main (commit 3ce64a2)
- **Cluster**: TKE, 3 CN + 1 DN
- **CN memory limit**: 55 GiB
- **DN memory limit**: 55 GiB

## 期望行为

测试应该在短时间内完成,而不是 68 分钟。

## 可能原因

1. **PK Index 维护开销**: 插入 10 亿行数据到有 PK index 的表,index 维护开销可能很大
2. **内存压力**: 大量数据插入可能导致内存压力,触发 GC
3. **Shuffle 开销**: 数据 shuffle 到不同 CN 可能很慢
4. **Lock 竞争**: PK index 维护可能导致 lock 竞争

## 建议调查方向

1. **对比历史数据**: 对比以前成功运行的耗时,确认退化程度
2. **检查内存使用**: 检查执行期间的内存使用,是否有 OOM 或 GC 压力
3. **检查 CPU 使用**: 检查 CPU 使用率,是否有瓶颈
4. **检查 lock 竞争**: 检查是否有 lock 竞争导致的性能问题
5. **Profile 分析**: 使用 Pyroscope 分析执行期间的 CPU 和内存 profile

## 相关

- Job: https://github.com/matrixorigin/mo-nightly-regression/actions/runs/29977409547/job/89130417745
- Commit: 3ce64a2

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.