Query optimization: join prunning and "uniqeness"

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

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

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

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
rust
領域
backend

調査の方向性

Start by reading the query transformation and relation metadata code that tracks join conditions and uniqueness; the issue does not name specific files or tests. The proposed optimization also needs a way to determine whether right-side columns are used in the output. Done means safely removing eligible left joins without changing query results; investigate existing tests for join transformations and add coverage for the stated conditions.

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

説明

compiler language-design

Under certain conditions, join transforms could be removed from the query without changing its result. This would have significantly improve query performance.

Example:

from e = employees
join side:left addresses (e.id == that.employee_id)
select {e.name}

... could be simplified into:

from e = employees
select {e.name}

Conditions:

  1. when there is a join of left relation with right relation,
  2. and it is a left join (so no left rows are dropped),
  3. and right relation is unique on the join condition (so no left rows are duplicated),
  4. and none of the columns from the right relation are used in the output.

At the moment, PRQL does contain knowledge to detect the conditions 1.-3., but not 4., so this is not possible to implement.

It would be possible to have this "uniqueness" information either:

  • declared at relation definition site (in SQL terms, this would be a UNIQUE constraint / PRIMARY KEY),
  • inferred from the query (if there is a group x (take 1), we can infer uniqueness on x).
    Then, it would be possible to detect condition 4.
主要言語
Rust
スター
10.9k
フォーク
261
平均マージ
3日 21時間
マージ済み PR(30日)
84

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

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

PRQL/prql のほかの issue

PRQL/prql の issue をすべて見る

似ている issue

Rust の issue をもっと見る

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

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