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

WIP: MDEV-34041 Display additional information for materialized subqueries… #3241

Open
wants to merge 2 commits into
base: 10.5
Choose a base branch
from

Conversation

Olernov
Copy link
Contributor

@Olernov Olernov commented May 4, 2024

… in EXPLAIN/ANALYZE FORMAT=JSON

  • The Jira issue number for this PR is: MDEV-34041

Description

This is a WIP (work-in-progress) PR, that's why the test suite is not updated. The ANALYZE output format is open for discussion, so it makes sense to update existing tests after the output format is approved

Release Notes

TODO: What should the release notes say about this change?
Include any changed system variables, status variables or behaviour. Optionally list any https://mariadb.com/kb/ pages that need changing.

How can this PR be tested?

TODO: modify the automated test suite to verify that the PR causes MariaDB to behave as intended.
Consult the documentation on "Writing good test cases".

If the changes are not amenable to automated testing, please explain why not and carefully describe how to test manually.

Basing the PR against the correct MariaDB version

  • This is a new feature and the PR is based against the latest MariaDB development branch.
  • This is a bug fix and the PR is based against the earliest maintained branch in which the bug can be reproduced.

PR quality check

  • I checked the CODING_STANDARDS.md file and my PR conforms to this where appropriate.
  • For any trivial modifications to the PR, I am ok with the reviewer making the changes themselves.

@Olernov Olernov requested a review from spetrunia May 4, 2024 13:07
Copy link
Member

@spetrunia spetrunia left a comment

Choose a reason for hiding this comment

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

Currently, there are two kinds of data structures:

  • EXPLAIN data structure
  • Tracker.

Explain_subq_materialization tries to be both. I know this is caused by
the fact that there's really no query plan.

I would still request to have the Explain class and the tracker class
explicitly. Even if the Explain class has only one member, the tracker.

The tracker class should follow other tracker classes:

  • data members are private.

  • execution code calls functions to report data

  • printing json output is done by local members.

  • constructor initalizes everything to some initial state which
    can already be printed (currently it doesn't). This is to allow
    SHOW ANALYZE and also the situation where subquery is never invoked.

partial_match_buffer_size);
}

for(uint i= 0; i < partial_match_merge_keys_counts.elements(); i++)
Copy link
Member

Choose a reason for hiding this comment

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

Any reason for not printing a JSON array here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree, fixed in the new revision

},
"subqueries": [
{
"subquery_materialization": {
Copy link
Member

Choose a reason for hiding this comment

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

Can this be just materialization ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, fixed

if (is_analyze)
{
writer->add_member("r_exec_strategy").add_str(
exec_strategy_str[exec_strategy]);
Copy link
Member

Choose a reason for hiding this comment

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

is "exec" redundant in r_exec_strategy, can we just use r_strategy ?

Looking at the enum of strategies, I don't see many that make sense:

{
  "undefined", "complete_match", "partial_match", "partial_match_merge",
  "partial_match_scan", "impossible"
};

undefined makes sense if the execution never reached the code that determines the strategy.
complete match means "only do index lookup", perhaps we should just print "index_lookup".
partial_match - this does not occur in practice, does it?
partial_match_scan and partial_match_merge are ok.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree with r_strategy. The enum of strategies indeed looks excessive, partial_match and impossible don't seem to be used anywhere. Do you think we can shrink subselect_hash_sj_engine::exec_strategy?

Copy link
Member

@spetrunia spetrunia left a comment

Choose a reason for hiding this comment

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

I think it also makes sense to introduce r_loops in subquery_materialization (to be materialization)

@Olernov
Copy link
Contributor Author

Olernov commented May 18, 2024

I think it also makes sense to introduce r_loops in subquery_materialization (to be materialization)

I don't understand what should be counted/tracked under this counter. Every lookup in the materialized subquery?

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