[Bug] MERGE double-counts updated rows when using Split Merge
维护者通常 2 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 56/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- c, postgresql
调研方向
Start by tracing how Split Merge represents an UPDATE and how the PostgreSQL planner reports affected rows for MERGE; the issue names no source files or tests, so locate the implementation and existing MERGE regression coverage first. Reproduce the supplied SQL with the PostgreSQL planner on a three-segment cluster, then add regression coverage showing that 20 logical updates report MERGE 20, not MERGE 40.
由索引模型根据 Issue 内容生成。
描述
Apache Cloudberry version
Reported during review of PR #2374, with the PostgreSQL planner on a three-segment cluster.
What happened
A MERGE that updates a distribution key uses Split Merge and reports MERGE 40, although only 20 target rows are updated.
Each target row matches exactly one source row. The reported count appears to include both the DELETE and INSERT halves of each split UPDATE.
What you think should happen instead
No response
How to reproduce
SET optimizer = off;
CREATE TABLE mg AS
SELECT a, 5 b FROM generate_series(1, 20) a
DISTRIBUTED BY (a);
CREATE TABLE mg_ref AS
SELECT generate_series(1, 20) a
DISTRIBUTED BY (a);
EXPLAIN (COSTS OFF)
MERGE INTO mg
USING mg_ref s ON mg.b = s.a
WHEN MATCHED THEN UPDATE SET a = 15;
MERGE INTO mg
USING mg_ref s ON mg.b = s.a
WHEN MATCHED THEN UPDATE SET a = 15;
Both CREATE TABLE statements report:
SELECT 20
The execution plan is:
QUERY PLAN
------------------------------------------------------------------------
Merge on mg
-> Explicit Redistribute Motion 3:3 (slice1; segments: 3)
-> Split Merge
-> Hash Join
Hash Cond: (mg.b = s.a)
-> Redistribute Motion 3:3 (slice2; segments: 3)
Hash Key: mg.b
-> Seq Scan on mg
-> Hash
-> Seq Scan on mg_ref s
Optimizer: Postgres query optimizer
(11 rows)
The MERGE command reports:
MERGE 40
should be:
MERGE 20
All 20 target rows have b = 5 and match the single source row with a = 5. Each logical UPDATE should contribute one affected row, regardless of whether execution splits it into DELETE and INSERT operations.
Operating System
any
Anything else
No response
Are you willing to submit PR?
- Yes, I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct.
- 主要语言
- C
- 星标
- 1.5k
- 派生
- 280
- 平均合并
- 4 天 21 小时
- 30 天内合并 PR
- 122
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
apache/cloudberry 的其他 Issue
-
type: Bug
难度 2/5 1-3 小时 新手友好度 78/100
apache/cloudberry#2459 · 1 条评论 ·
维护者通常 2 天内回复
-
psql tab completion broken for storage servers, tags, profiles and resource groups (pre-PG15 query format)可能已有人在做 @allenvox 于 18 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
apache/cloudberry#2316 ·
维护者通常 2 天内回复
-
gpexpand first stage fails: 'SyncPackages' object has no attribute 'ret' (extension sync never runs; regression)可能已有人在做 @talmacschen-arch 于 166 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 86/100
apache/cloudberry#1825 ·
维护者通常 2 天内回复
-
[Bug] ORCA returns wrong system column values through a partially pruned CTE consumer可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭type: Bug
难度 4/5 3-5 天 新手友好度 48/100
apache/cloudberry#2458 · 1 条评论 ·
维护者通常 2 天内回复
-
[Bug] Window Sort above ROLLUP gets a larger memory quota and runs slower after "Reserve memory for one partition at a time"可能已有人在做 @Alena0704 于 1 天前认领。 未关闭type: Bug
难度 4/5 3-5 天 新手友好度 52/100
apache/cloudberry#2446 · 已指派 1 人 ·
维护者通常 2 天内回复
查看 apache/cloudberry 的全部 Issue
相似的 Issue
-
难度 1/5 1-3 小时 新手友好度 82/100
-
难度 2/5 1-3 小时 新手友好度 90/100
ly05010419/MacNativeGames#2459 ·
维护者通常 1 天内回复
-
2024.2 Backport Required 2025.2 Backport Required 2026.1 Backport Required 2026.2 Backport Required area/build-framework kind/enhancement priority/medium
难度 2/5 1-3 小时 新手友好度 74/100
yugabyte/yugabyte-db#39930 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
shinyquagsire23/OpenJKDF2#540 ·
维护者通常 12 天内回复
-
Prison work hall: laundry and kitchen stations stand at bare walls, the hatch has no counter or sign未关闭
难度 2/5 1-3 小时 新手友好度 78/100
Life-Framework/Life-Framework#5939 ·
维护者通常 1 天内回复