h2database / h2database/h2database
Feature: Materialized CTE
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 4.6k
- Forks
- 1.3k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 9
Description
In context of recursive CTEs I've noticed a significant performance impact when addressing CTE in subqueries.
My assumption is, as soon as recursive CTE is queried the whole recursion is triggered from the very beginning.
The simple solution could be to materialize the result of recursion in TEMP TABLE or MATERIALIZED VIEW. However it is a separate update operation. What would be really nice to have a materialized CTE, similar to what Postgres supports: WITH MY_CTE AS MATERIALIZED (SELECT * FROM SOURCE) SELECT * FROM MY_CTE
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing H2's recursive CTE handling and its behavior when a CTE is referenced from subqueries. Compare the requested PostgreSQL-style MATERIALIZED syntax and semantics; done means the syntax is accepted and recursive results are materialized for subsequent references without requiring a separate update operation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, sql
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100