citusdata / citusdata/citus

Emphasize difference between relational and non-relational filter clauses in code

Open
#871 0 comments 0 reactions 0 assignees View on GitHub
1-2 days technical debt
Dominant language
C
Stars
12.8k
Forks
794
Avg merge
2d 14h
Merged PRs (30d)
31

Description

Citus' logical planner optimizes a query by pulling up / pushing down multi-relational algebra operators. To do this, the logical planner first finds the filter clauses in the query, and then extracts relation ids (tables) from the filter clauses. Using these relation ids, the planner can optimize relational algebra pull up / push downs.

This logic doesn't play well with non-relational filter clauses; for example `WHERE 1=0` (#803).

We still need to keep the filter clause however -- the physical planner needs to evaluate all filter clauses for partition and join pruning.

We fixed this issue by skipping over filter clauses that don't have relations in the logical planner. The more explicit way to fix this is by introducing another list, non-relational select clauses, and simply ignoring items in this list in the logical planner. (Alternatively, we could also more thoroughly explain in the comments as to _why_ we're skipping over filter clauses.)

Contributor guide

Open the contributing guide

Research direction

Start by locating the logical planner code that finds and extracts relation IDs from filter clauses, then compare it with the physical planner's handling of all filter clauses. The change is done when non-relational clauses are clearly distinguished from relational ones without preventing physical-planner evaluation, using either a separate list or clearer comments.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, postgresql, sql
Domain
databases
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.