Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン
#2,026 コメント 1 件 リアクション 1 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
52/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
c, postgresql, sql
領域
databases

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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
主要言語
C
スター
1.4k
フォーク
260
平均マージ
4日 5時間
マージ済み PR(30日)
51

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/cloudberry のほかの issue

apache/cloudberry の issue をすべて見る

似ている issue

C の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。