[Bug] MERGE double-counts updated rows when using Split Merge
Mantenedores costumam responder em até 2 dias
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 56/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Stack de tecnologia
- c, postgresql
- Domínio
- backend-api-design, databases
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- C
- Estrelas
- 1.5k
- Forks
- 280
- Merge médio
- 5d 35min
- PRs com merge (30d)
- 128
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de apache/cloudberry
-
type: Bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
apache/cloudberry#2459 · 1 comentário ·
Mantenedores costumam responder em até 2 dias
-
psql tab completion broken for storage servers, tags, profiles and resource groups (pre-PG15 query format)Talvez já em andamento @allenvox assumiu há 18 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
apache/cloudberry#2316 ·
Mantenedores costumam responder em até 2 dias
-
gpexpand first stage fails: 'SyncPackages' object has no attribute 'ret' (extension sync never runs; regression)Talvez já em andamento @talmacschen-arch assumiu há 166 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 86/100
apache/cloudberry#1825 ·
Mantenedores costumam responder em até 2 dias
-
[Bug] ORCA returns wrong system column values through a partially pruned CTE consumerTalvez já em andamento @yjhjstz assumiu hoje. Abertatype: Bug
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 48/100
apache/cloudberry#2458 · 1 comentário ·
Mantenedores costumam responder em até 2 dias
-
[Bug] Window Sort above ROLLUP gets a larger memory quota and runs slower after "Reserve memory for one partition at a time"Talvez já em andamento @Alena0704 assumiu há 1 dia. Abertatype: Bug
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 52/100
apache/cloudberry#2446 · 1 responsável ·
Mantenedores costumam responder em até 2 dias
Todas as issues de apache/cloudberry
Issues semelhantes
-
HXsetdir strdup leakAberta
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 82/100
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 90/100
ly05010419/MacNativeGames#2459 ·
Mantenedores costumam responder em até 1 dia
-
2024.2 Backport Required 2025.2 Backport Required 2026.1 Backport Required 2026.2 Backport Required area/build-framework kind/enhancement priority/medium
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
yugabyte/yugabyte-db#39930 ·
Mantenedores costumam responder em até 1 dia
-
RecompLauncher supportAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
shinyquagsire23/OpenJKDF2#540 ·
Mantenedores costumam responder em até 12 dias
-
Prison work hall: laundry and kitchen stations stand at bare walls, the hatch has no counter or signAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Life-Framework/Life-Framework#5939 ·
Mantenedores costumam responder em até 1 dia