Push down subqueries on reference tables when result is deterministic
- Dominant language
- C
- Stars
- 12.8k
- Forks
- 794
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 31
Description
We currently do not push down subqueries that do not pass the checks in `DeferErrorIfCannotPushdownSubquery`, even if the subquery contains no distributed tables.
For subqueries with deterministic result sets across all workers, we could push them down, while for non-deterministic results we should use recursive planning.
Examples of deterministic results:
```sql
SELECT * FROM reference_table ORDER BY x LIMIT 10
SELECT max(x) FROM reference_table
SELECT * FROM reference_table UNION SELECT * FROM other_reference_table
```
Examples of non-deterministic results:
```sql
SELECT * FROM reference_table LIMIT 10
SELECT DISTINCT ON (x), y FROM reference_table
SELECT * FROM reference_table WHERE x < random()
```
related to #1872
Contributor guide
Assessment
This issue has not been assessed yet.