Skip to content
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

Enhance explain #146

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft

Enhance explain #146

wants to merge 1 commit into from

Conversation

kysshsy
Copy link
Contributor

@kysshsy kysshsy commented Oct 7, 2024

Ticket(s) Closed

What

Why

How

Support the ANALYZE option: add a timer to record the actual execution time.
Support the STYLE option: Provide the query plan and execution time in DuckDB style.

Tests

@kysshsy
Copy link
Contributor Author

kysshsy commented Oct 7, 2024

It depends on sqlparser apache/datafusion-sqlparser-rs#1426. Awaiting the next release of the library.


macro_rules! fallback_warning {
($msg:expr) => {
warning!("This query was not fully pushed down to DuckDB because DuckDB returned an error. Query times may be impacted. If you would like to see this query pushed down, please submit a request to https://github.com/paradedb/paradedb/issues with the following context:\n{}", $msg);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should say paradedb/pg_analytics instead of paradedb/paradedb

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change it in #140

@philippemnoel
Copy link
Collaborator

Should this be based off of #140?

@kysshsy
Copy link
Contributor Author

kysshsy commented Oct 9, 2024

Should this be based off of #140?

:) It actually doesn’t depend on #140; it’s just that part of them are the same. (split the explain in a single file.)

@philippemnoel
Copy link
Collaborator

Should this be based off of #140?

:) It actually doesn’t depend on #140; it’s just that part of them are the same. (split the explain in a single file.)

Got it. Let's still get the PREPARE PR in first though, since this one is blocked. Thank YOU for doing this, your PRs are always so clean!

Ok(r)
})?;

Ok(rows.join(""))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just adds a new row right?

Comment on lines +57 to +71
Style::Postgres => {
let mut output = format!("DuckDB Scan: {}\n", query);
if state.analyze {
let start_time = Instant::now();
set_search_path_by_pg()?;
connection::execute(&query, [])?;
let duration = start_time.elapsed();
output += &format!(
"Execution Time: {:.3} ms\n",
duration.as_micros() as f64 / 1_000.0
);
}
output
}
Style::Duckdb => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is cool. What do you see as the use case for supporting both styles? Is there anything the DuckDB style offers that can't be in a single style?

I don't want to increase cognitive load on the user. Ideally, they wouldn't need to pass any setting to EXPLAIN if they can avoid it. What do you think?

Copy link
Collaborator

@philippemnoel philippemnoel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please provide output examples for all the style/options you are adding here? I.e. what the query looks like, and what the output looks like? I'd like to build a better understanding of what this will look like before we merge anything.

Also some tests, but I understand this PR isn't ready for review yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhance EXPLAIN Statement: Add analyze option, Support style option
2 participants