[Bug]

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

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

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

評価

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

調査の方向性

Start with src/backend/gpopt/translate/CTranslatorQueryToDXL.cpp and the optimizer_enable_multiple_distinct_aggs definition in guc_gp.c; the issue identifies the guard that causes fallback. Check how the optimizer handles multiple distinct qualified aggregates and review existing tests for that behavior. Done means establishing whether enabling the option is supported and safe, with evidence about plan behavior and the reason it defaults off.

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

説明

type: Bug
Apache Cloudberry version
Environment
  • Cloudberry version: <Ausgabe von SELECT version(); einfügen>
  • Segments: 4
  • optimizer = on
  • join_collapse_limit = 20, from_collapse_limit = 20 (defaults)
What happened
Environment
  • Cloudberry version: <Ausgabe von SELECT version(); einfügen>
  • Segments: 4
  • optimizer = on
  • join_collapse_limit = 20, from_collapse_limit = 20 (defaults)
Description

A BI tool (Yellowfin) generates queries with several COUNT(DISTINCT ...) on different columns.
GPORCA refuses these queries and falls back to the Postgres-based planner:

INFO:  GPORCA failed to produce a plan, falling back to planner
DETAIL:  Feature not supported: Multiple Distinct Qualified Aggregates are disabled in the optimizer

In our case the query joins ~20 tables (LEFT JOINs) with 7 COUNT(DISTINCT ...) and a wide GROUP BY.
After the fallback, the Postgres planner (with join_collapse_limit = 20) needs a very long time to plan:

Planning Time: 192018.556 ms
Optimizer: Postgres query optimizer
Execution Time: 50.880 ms

So the fallback itself turns a trivial query into a ~3 minute planning-only operation.

Questions
  1. Is this limitation still in place in the latest Cloudberry release, or is there a version where ORCA handles multiple DQAs by default?
  2. Is it safe/supported to set optimizer_enable_multiple_distinct_aggs = on in production (e.g. per role), given it is classified as a developer option? Are there known issues or plan-quality regressions (CXformGbAggWithMDQA2Join)?
  3. Is there a reason why the default is off (performance, correctness)?
  4. Are there recommendations to limit the planning time after an ORCA fallback for queries with many joins (e.g. lowering join_collapse_limit / from_collapse_limit for such roles)?

Thanks!

What you think should happen instead

No response

How to reproduce
Minimal reproduction
CREATE TABLE t_mdqa (a int, b int, c int) DISTRIBUTED BY (a);
SET optimizer = on;
SET optimizer_trace_fallback = on;
EXPLAIN SELECT count(DISTINCT a), count(DISTINCT b) FROM t_mdqa GROUP BY c;
-- -> falls back to Postgres-based planner

As far as I can see, the check is still present in current main
(src/backend/gpopt/translate/CTranslatorQueryToDXL.cpp:
if (1 < num_dqa && !optimizer_enable_multiple_distinct_aggs)),
and optimizer_enable_multiple_distinct_aggs is defined as a DEVELOPER_OPTIONS GUC in guc_gp.c.

Operating System

NAME="Red Hat Enterprise Linux" VERSION="8.10 (Ootpa)" ID="rhel" ID_LIKE="fedora" VERSION_ID="8.10" PLATFORM_ID="platform:el8" PRETTY_NAME="Red Hat Enterprise Linux 8.10 (Ootpa)" ANSI_COLOR="0;31" CPE_NAME="cpe:/o:redhat:enterprise_linux:8::baseos" HOME_URL="https://www.redhat.com/" DOCUMENTATION_URL="https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8" BUG_REPORT_URL="https://issues.redhat.com/" REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 8" REDHAT_BUGZILLA_PRODUCT_VERSION=8.10 REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux" REDHAT_SUPPORT_PRODUCT_VERSION="8.10" Red Hat Enterprise Linux release 8.10 (Ootpa) Red Hat Enterprise Linux release 8.10 (Ootpa)

Anything else

No response

Are you willing to submit PR?
  • Yes, I am willing to submit a PR!
Code of Conduct
主要言語
C
スター
1.4k
フォーク
268
平均マージ
4日 3時間
マージ済み PR(30日)
78

環境構築

はじめの一歩

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

apache/cloudberry のほかの issue

apache/cloudberry の issue をすべて見る

似ている issue

C の issue をもっと見る

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

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