You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] GPORCA: ERROR "btree index keys must be ordered by attribute" when a qual references an INCLUDE column #2026
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
CREATETABLEc2t(a int, b int) DISTRIBUTED BY (a);
CREATEINDEXci1ON 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:
CREATETABLEc1t(a int, b int) DISTRIBUTED BY (a);
CREATEINDEXci0ON c1t USING btree (a) INCLUDE (a, b);
SET optimizer =on;
SELECT a, b FROM c1t WHERE b IS NULLGROUP 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.
Activity
yjhjstz commentedon Sep 21, 2026
fix #1957