Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

[Bug] GPORCA: ERROR "btree index keys must be ordered by attribute" when a qual references an INCLUDE column

Abierto
#2,026 1 comentario 1 reacción 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
52/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
c, postgresql, sql
Área
databases

Línea de trabajo

Start by reproducing the SQL examples with GPORCA enabled, then compare the plans and results with the optimizer disabled. Trace how the btree INCLUDE column reaches the Index Cond; done means INCLUDE columns are not used as scan keys and the queries complete without the runtime error.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

type: Bug
Apache Cloudberry version

No response

What happened

With GPORCA (optimizer = on), a qual on a btree index's INCLUDE (non-key) column can be pushed into the Index Cond. INCLUDE columns are payload only and are not searchable, so the executor
rejects the scan keys at runtime:

ERROR:  btree index keys must be ordered by attribute (nbtutils.c:799)

The Postgres planner (optimizer = off) is not affected. The table does not need to contain any rows.

What you think should happen instead

No response

How to reproduce
CREATE TABLE c2t(a int, b int) DISTRIBUTED BY (a);
CREATE INDEX ci1 ON c2t USING btree (a) INCLUDE (b);

SET optimizer = on;
SELECT a, b FROM c2t WHERE b IS NULL;
-- ERROR:  btree index keys must be ordered by attribute (nbtutils.c:799)  (seg2 slice1 ...)

The plan puts the INCLUDE column b into the Index Cond:

EXPLAIN (COSTS OFF) SELECT a, b FROM c2t WHERE b IS NULL;

 Gather Motion 3:1  (slice1; segments: 3)
   ->  Index Scan using ci1 on c2t
         Index Cond: (b IS NULL)
 Optimizer: GPORCA

Same error with GROUP BY and with an index whose INCLUDE list repeats a key column:

CREATE TABLE c1t(a int, b int) DISTRIBUTED BY (a);
CREATE INDEX ci0 ON c1t USING btree (a) INCLUDE (a, b);
SET optimizer = on;
SELECT a, b FROM c1t WHERE b IS NULL GROUP BY a, b;
-- ERROR:  btree index keys must be ordered by attribute (nbtutils.c:799)

With SET optimizer = off; all of the above return the correct rows.

Operating System

any

Anything else

No response

Are you willing to submit PR?
  • Yes, I am willing to submit a PR!
Code of Conduct
Lenguaje dominante
C
Estrellas
1.4k
Forks
248
Merge medio
4 d 10 h
PR fusionados (30 d)
40

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de apache/cloudberry

Todos los issues de apache/cloudberry

Issues similares

Más issues de C

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.