-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Printer for the plan, ie: EXPLAIN #2075
base: master
Are you sure you want to change the base?
Conversation
be18b08
to
81adebc
Compare
1ca3567
to
75e1cbd
Compare
1d25e4f
to
305e0bc
Compare
305e0bc
to
33c8978
Compare
@@ -166,10 +166,12 @@ pub fn type_subscription(ast: SqlSelect, tx: &impl SchemaView) -> TypingResult<P | |||
|
|||
/// Parse and type check a *subscription* query into a `StatementCtx` | |||
pub fn compile_sql_sub<'a>(sql: &'a str, tx: &impl SchemaView) -> TypingResult<StatementCtx<'a>> { | |||
let planning_time = std::time::Instant::now(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make planning time external? So that we don't compute it during normal execution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So create a wrapper? Because the alternative is to parse EXPLAIN
"select * from t", | ||
expect![[r#" | ||
Seq Scan on t | ||
Output: t.id, t.x"#]], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove the Output
section, or at least make it optional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The last Output
is always show in pg
. BTW It also show the output in each node of the plan.
It has help me to sport problems so I think is a good check to keep.
/// x: join | ||
/// p: project | ||
/// s: select | ||
/// ix: index scan | ||
/// rx: right index semijoin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: A double space at the end of a doc comment line is interpreted as a new line by the formatter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This spaces are removed by rustfmt
crates/physical-plan/src/plan.rs
Outdated
-> Index Scan using Index id 0: (identity) on u | ||
-> Index Cond: (u.identity = U64(5)) | ||
-> Inner Unique: true | ||
-> Index Cond: (u.entity_id = p.entity_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These arrows should all have the same indentation, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which ones?:
Only the first two?
crates/physical-plan/src/plan.rs
Outdated
-> Index Cond: (u.identity = U64(5)) | ||
-> Inner Unique: true | ||
-> Index Cond: (u.entity_id = p.entity_id) | ||
-> Inner Unique: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have outer joins, so should this just be Unique: false
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well this is what the IxJoin
pass.
crates/physical-plan/src/plan.rs
Outdated
&db, | ||
sql, | ||
expect![[r#" | ||
Hash Join: All |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hash Join: All | |
Hash Join |
All
means it's not a semijoin. So it would probably be clearer to just call it HashJoin
in that case.
-> Seq Scan on m | ||
-> Seq Scan on n | ||
-> Inner Unique: false | ||
-> Hash Cond: (m.manager = n.manager) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-> Hash Cond: (m.manager = n.manager) | |
-> Join Cond: (m.manager = n.manager) |
crates/physical-plan/src/plan.rs
Outdated
-> Inner Unique: false | ||
-> Index Cond: (p.chunk = q.chunk) | ||
Inner Unique: true | ||
Index Cond: (q.entity_id = b.entity_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Index Cond: (q.entity_id = b.entity_id) | |
Join Cond: (q.entity_id = b.entity_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is consistent to how pg
show the plan:
SELECT * FROM auth_user a JOIN auth_user b ON a.username = b.username where a.username = 'a'
Nested Loop (cost=0.29..16.34 rows=1 width=386) (actual time=21.830..21.831 rows=0 loops=1)
Output: a.username, a.name, a.email, a.password, a.role, a.is_active, a.dot, b.username, b.name, b.email, b.password, b.role, b.is_active, b.dot
-> Index Scan using auth_user_pkey on betatest.auth_user a (cost=0.15..8.17 rows=1 width=193) (actual time=21.829..21.830 rows=0 loops=1)
Output: a.username, a.name, a.email, a.password, a.role, a.is_active, a.dot
Index Cond: (a.username = 'a'::text COLLATE nd)
-> Index Scan using auth_user_pkey on betatest.auth_user b (cost=0.15..8.17 rows=1 width=193) (never executed)
Output: b.username, b.name, b.email, b.password, b.role, b.is_active, b.dot
Index Cond: (b.username = 'a'::text COLLATE nd)
crates/physical-plan/src/plan.rs
Outdated
sql, | ||
expect![ | ||
r#" | ||
Index Scan using Index id 2: (x, y, z) on t |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Index Scan using Index id 2: (x, y, z) on t | |
Index Scan using index id: 2 |
Can we must mention the index id in this part, and then have the index info in the metadata section?
crates/physical-plan/src/plan.rs
Outdated
------- | ||
Schema: | ||
|
||
Label m: 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to mention the Label
ids. The names are sufficient.
But can we add the TableId
?
33c8978
to
f8700bc
Compare
Description of Changes
Incipient support for
EXPLAIN
with close plan output as inPostgres
(but not yet conformant).It has the extra capability of showing extra metadata about the schema & indexes, useful for testing & debugging.
NOTE: In
draft
because we want to coordinate with @joshua-spacetime about what will be the desirable testing changes...Example:
Closes #2058.
API and ABI breaking changes
None
Expected complexity level and risk
1
Testing