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

[CBRD-24537] Improve the performance of MERGE query by using NOT EXISTS sub-query #3919

Merged
merged 8 commits into from
Nov 23, 2022

Conversation

beyondykk9
Copy link
Contributor

http://jira.cubrid.org/browse/CBRD-24537

The MERGE query's "NOT MATCHED" part is rewritten by using COUNT query for checking "NOT MATCHED", however, the performance of COUNT query is not good compared with NOT EXISTS query.

We will enhance the performance of the MERGE query by using "NOT EXISTS" sub-query instead of COUNT query.

@beyondykk9 beyondykk9 added this to the fig milestone Oct 28, 2022
@beyondykk9 beyondykk9 self-assigned this Oct 28, 2022
@beyondykk9 beyondykk9 marked this pull request as draft October 31, 2022 01:16
@beyondykk9 beyondykk9 marked this pull request as ready for review November 18, 2022 02:07
Comment on lines +25213 to +25226
if (expr)
{
if (expr->info.expr.arg1)
{
parser_free_tree (parser, expr->info.expr.arg1);
corr_subq = NULL;
}
parser_free_tree (parser, expr);
}

if (corr_subq)
{
parser_free_tree (parser, corr_subq);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

How about below?

Suggested change
if (expr)
{
if (expr->info.expr.arg1)
{
parser_free_tree (parser, expr->info.expr.arg1);
corr_subq = NULL;
}
parser_free_tree (parser, expr);
}
if (corr_subq)
{
parser_free_tree (parser, corr_subq);
}
if (corr_subq)
{
parser_free_tree (parser, corr_subq);
}
if (expr)
{
parser_free_tree (parser, expr);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This code sequence is right because the expr could be assigend to corr_subq.

@@ -25111,7 +25111,7 @@ pt_to_merge_update_query (PARSER_CONTEXT * parser, PT_NODE * select_list, PT_MER
PT_NODE *
pt_to_merge_insert_query (PARSER_CONTEXT * parser, PT_NODE * select_list, PT_MERGE_INFO * info)
{
PT_NODE *subq, *corr_subq, *expr, *and_expr, *value;
PT_NODE *subq, *corr_subq = NULL, *expr = NULL, *and_expr = NULL, *value = NULL;
Copy link
Contributor

Choose a reason for hiding this comment

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

It is trivial.

Suggested change
PT_NODE *subq, *corr_subq = NULL, *expr = NULL, *and_expr = NULL, *value = NULL;
PT_NODE *subq = NULL, *corr_subq = NULL, *expr = NULL, *and_expr = NULL, *value = NULL;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

subq is always assigned some address as new node.

@beyondykk9 beyondykk9 merged commit e2391d3 into CUBRID:develop Nov 23, 2022
@beyondykk9 beyondykk9 deleted the CBRD-24537 branch November 23, 2022 00:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants