[Bug] GPORCA: ERROR "btree index keys must be ordered by attribute" when a qual references an INCLUDE column
Maintainers usually reply within 3 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 52/100
Research direction
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.
Written by the indexing model from the issue text.
Description
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
- I agree to follow this project's Code of Conduct.
- Dominant language
- C
- Stars
- 1.4k
- Forks
- 256
- Avg merge
- 4d 10h
- Merged PRs (30d)
- 46
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/cloudberry
-
[Bug] Expand fails to recognize user-defined tablespacesPossibly taken @nix-oss claimed this 47 days ago. Opentype: Bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
apache/cloudberry#1885 · 2 reactions ·
Maintainers usually reply within 3 days
-
gpexpand first stage fails: 'SyncPackages' object has no attribute 'ret' (extension sync never runs; regression)Possibly taken @talmacschen-arch claimed this 108 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
apache/cloudberry#1825 ·
Maintainers usually reply within 3 days
-
[Bug] UPDATE of the distribution key fails with "can't split update for inherit table" after the child table is droppedPossibly taken @aryan9948 claimed this 6 days ago. Opentype: Bug
Difficulty 3/5 1-2 days Newbie friendliness 65/100
apache/cloudberry#2048 · 5 comments · 1 reaction · 1 assignee ·
Maintainers usually reply within 3 days
-
[Bug] Wrong results: GPORCA evaluates a window function in a correlated aggregate subquery over all groupsPossibly taken @andr-sokolov claimed this 6 days ago. Opentype: Bug
Difficulty 4/5 3-5 days Newbie friendliness 40/100
apache/cloudberry#2047 · 1 assignee ·
Maintainers usually reply within 3 days
-
[Bug] Wrong results: GPORCA returns NULL instead of the empty-input value for correlated aggregate subqueries other than countPossibly taken @Alena0704 claimed this 6 days ago. Opentype: Bug
Difficulty 4/5 3-5 days Newbie friendliness 45/100
apache/cloudberry#2046 · 1 comment · 1 assignee ·
Maintainers usually reply within 3 days
All issues in apache/cloudberry
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
RPCS3/rpcs3#19705 · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
bug llvm
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
containers/bubblewrap#813 · 1 reaction ·
Maintainers usually reply within 1 day