Skip to content

Optimize mark joins + EmptyRelation #21391

@neilconway

Description

@neilconway

Is your feature request related to a problem or challenge?

  SELECT * FROM t1
  WHERE EXISTS (SELECT 1 FROM t2 WHERE t2.id = t1.id AND 1=0)
     OR t1.flag = true;

Yields

     +---------------+------------------------------------------------------------+
     | plan_type     | plan                                                       |
     +---------------+------------------------------------------------------------+
     | physical_plan | ┌───────────────────────────┐                              |
     |               | │         FilterExec        │                              |
     |               | │    --------------------   │                              |
     |               | │         predicate:        │                              |
     |               | │        mark OR flag       │                              |
     |               | └─────────────┬─────────────┘                              |
     |               | ┌─────────────┴─────────────┐                              |
     |               | │      RepartitionExec      │                              |
     |               | │    --------------------   │                              |
     |               | │ partition_count(in->out): │                              |
     |               | │          1 -> 16          │                              |
     |               | │                           │                              |
     |               | │    partitioning_scheme:   │                              |
     |               | │    RoundRobinBatch(16)    │                              |
     |               | └─────────────┬─────────────┘                              |
     |               | ┌─────────────┴─────────────┐                              |
     |               | │     NestedLoopJoinExec    │                              |
     |               | │    --------------------   ├──────────────┐               |
     |               | │    join_type: RightMark   │              │               |
     |               | └─────────────┬─────────────┘              │               |
     |               | ┌─────────────┴─────────────┐┌─────────────┴─────────────┐ |
     |               | │         EmptyExec         ││       DataSourceExec      │ |
     |               | │                           ││    --------------------   │ |
     |               | │                           ││         bytes: 264        │ |
     |               | │                           ││       format: memory      │ |
     |               | │                           ││          rows: 1          │ |
     |               | └───────────────────────────┘└───────────────────────────┘ |
     |               |                                                            |
     +---------------+------------------------------------------------------------+

But we could skip the entire NLJ, similar to #21321

Describe the solution you'd like

No response

Describe alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request
No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions