Query optimization: join prunning and "uniqeness"

未关闭
#4,487 3 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 5 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
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
平均合并
4 天 7 小时
30 天内合并 PR
77

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

PRQL/prql 的其他 Issue

查看 PRQL/prql 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。