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

Support Variable-Setting Hint SET_VAR #18748

Closed
zz-jason opened this issue Jul 23, 2020 · 2 comments · Fixed by #20232
Closed

Support Variable-Setting Hint SET_VAR #18748

zz-jason opened this issue Jul 23, 2020 · 2 comments · Fixed by #20232
Labels
feature/accepted This feature request is accepted by product managers help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. priority/P1 The issue has P1 priority. type/feature-request Categorizes issue or PR as related to a new feature.

Comments

@zz-jason
Copy link
Member

zz-jason commented Jul 23, 2020

Feature Request

Is your feature request related to a problem? Please describe:

TiDB supports lots of variables for applications. For example, tidb_opt_distinct_agg_push_down, the typical usage is:

set @original_value = @@tidb_opt_distinct_agg_push_down;
set @@tidb_opt_distinct_agg_push_down = 1;  -- enables aggregate pushdown through join
select ...;
set @@tidb_opt_distinct_agg_push_down = @original_value;

With this hint, there is no need to save and restore the variable value, the above example can be rewritten to:

select /*+ set_var(tidb_opt_distinct_agg_push_down=1) */ ...

#11703 also described another use case on tidb_snapshot.

Describe the feature you'd like:

Support the set_var hint like MySQL Variable-Setting Hint Syntax

Describe alternatives you've considered:

N/A

Teachability, Documentation, Adoption, Migration Strategy:

N/A

@zz-jason zz-jason added the type/feature-request Categorizes issue or PR as related to a new feature. label Jul 23, 2020
@zz-jason zz-jason added the help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. label Jul 27, 2020
@zz-jason zz-jason added the feature/accepted This feature request is accepted by product managers label Jul 29, 2020
@scsldb scsldb added the priority/P1 The issue has P1 priority. label Jul 29, 2020
@b41sh
Copy link
Member

b41sh commented Sep 3, 2020

SetExecutor is used to execute SET statements, can we use it to execute SET_VAR hint?
As SET_VAR hint takes effect temporarily, we can build two plannercore.Set in PlanBuilder.
The first is used to set the value of the session, the second change it back.

@qw4990
Copy link
Contributor

qw4990 commented Sep 3, 2020

SetExecutor is used to execute SET statements, can we use it to execute SET_VAR hint?
As SET_VAR hint takes effect temporarily, we can build two plannercore.Set in PlanBuilder.
The first is used to set the value of the session, the second change it back.

I think we cannot use SetExecutor directly here, since it is used to set variables in global or session level.
In this feature, the variable is in SQL level since it should be removed after finishing this SQL.
So I think it's better to introduce a new approach to set these SQL-level variables instead of reusing SetExecutor.

What're your options? @zz-jason @SunRunAway

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/accepted This feature request is accepted by product managers help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. priority/P1 The issue has P1 priority. type/feature-request Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants