Comments (5)
I cloned risinglight
and took a look today. I'm interested in the execution plans generated by Q9 duckdb
and risinglight
. I haven't had a chance to look closely yet. I noticed that the tree generated by duckdb
is more "balanced", while the tree generated by risinglight
is somewhat "skewed". I'm happy to continue working on this issue 😃
from risinglight.
Hi @xiaguan , thanks for your interest! The reason for the "skewed" tree in RisingLight is that:
- The binder generates a left-deep tree of join nodes in the execution plan.
- In the optimizer, although we have a join-reordering rule to rotate this tree, it seems that this optimization doesn't work as we expected.
risinglight/src/planner/rules/plan.rs
Lines 95 to 99 in 604b4a1
As you can see, this rule is conditional and may not work if the condition is not met after predicate pushdown.
We can change it to an unconditional rule so that all combinations can be covered.
rw!("join-reorder";
"(join ?type ?cond2 (join ?type ?cond1 ?left ?mid) ?right)" =>
"(join ?type (and ?cond1 ?cond2) ?left (join ?type true ?mid ?right))"
),
Another defect of the optimizer is that we don't swap the children of a join node now. That is to say, (A join B) join C
can not be reordered to B join (A join C)
.
A possible solution may be like this:
rw!("join-swap";
"(proj ?exprs (join ?type ?cond ?left ?right))" =>
"(proj ?exprs (join ?type ?cond ?right ?left))"
),
Notice that we put a proj
node above the join, otherwise the new plan will have a different column order with the old plan, which breaks the equality semantic.
These are some of my ideas. But they have not been proven to work. If you are interested, feel free to continue this work!
from risinglight.
risinglight/src/planner/rules/rows.rs
Line 24 in a0882cd
- The first issue is that the estimation of scan in the
cost()
function is not implemented correctly. This means that during the construction process of the egraph, the number of rows for a data table is defaulted to 1000. We may be able to solve this by using a global binder? - The second issue is that we cannot control our memory usage. When running q9 with 1gb on my machine, it can take up to 20gb of memory.
I will continue to try to solve these two problems.
from risinglight.
For the first issue, yes, we should provide row number information from storage to the optimizer. Currently, row number statistics are available in disk storage but not in memory storage.
For the second issue, we can reduce the memory usage by optimizing the hash join executor. Now it collects all input chunks from both side at the beginning (code). This can be refactored into a streaming style. Besides, a better join order may also help reduce the memory usage.
from risinglight.
rw!("join-swap";
"(proj ?exprs (join ?type ?cond ?left ?right))" =>
"(proj ?exprs (join ?type ?cond ?right ?left))"
),
The rule you provided above works. My other attempts have all failed. I plan to take a look at other problems.
from risinglight.
Related Issues (20)
- sql: support subquery HOT 2
- api: support JDBC HOT 2
- api: support Postgres wire protocol HOT 1
- Regarding setting up rust toolchain in development guide HOT 1
- executor: improve the performance of hash join and group by aggregation HOT 1
- Tracking: support ClickBench
- type: support TIMESTAMP HOT 1
- perf: store small decimal values as int HOT 1
- expr: avoid div by zero error when vectorization HOT 2
- expr: explicit SIMD HOT 7
- optimizer: push any filter down to storage HOT 3
- sqllogictest: `filter.slt` duplicate primary key HOT 1
- bug: header seems to be None all the time HOT 2
- explain: improve projection explain HOT 2
- `select *` panic in subquery HOT 4
- feat: support streaming queries HOT 2
- optimizer: filter scan rule HOT 2
- rlslngllgt -> risinglight
- feat: support wal
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from risinglight.