ClickHouse / ClickHouse/ClickHouse

Lateral Joins

Open
#29,504 2 comments 22 reactions 0 assignees View on GitHub
comp-joins comp-sql-syntax external feature
Dominant language
C++
Stars
49.9k
Forks
9k
Avg merge
21h 32m
Merged PRs (30d)
515

Description

> (you don't have to strictly follow this form)

Lateral joins are fantastic for workloads primarily used in ClickHouse environments: time-series/logs/analytics/etc. that trace the history of an object's values throughout time

in particular, lateral joins make writing correlated subqueries far easier

```
SELECT * FROM (
SELECT DISTINCT ON (ID) *
WHERE ID = ANY($1)
FROM PRICES
ORDER BY ID, TIMESTAMP DESC
) PRICE LEFT JOIN LATERAL (
..... other info
) LEFT JOIN LATERAL (
..... other info
)
```

> A clear and concise description of what is the intended usage scenario is.

Support for lateral joins

Why not use normal joins? It will duplicate rows during join process before filtering on distinct at the end, causing major performance degradation

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.