-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
*:add opt_rule_blacklist in mysql tables. (#11096)
- Loading branch information
Showing
27 changed files
with
216 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use test; | ||
drop table if exists t; | ||
create table t (a int); | ||
explain select * from t where a < 1; | ||
id count task operator info | ||
TableReader_7 3323.33 root data:Selection_6 | ||
└─Selection_6 3323.33 cop lt(test.t.a, 1) | ||
└─TableScan_5 10000.00 cop table:t, range:[-inf,+inf], keep order:false, stats:pseudo | ||
insert into mysql.opt_rule_blacklist values('predicate_push_down'); | ||
admin reload opt_rule_blacklist; | ||
|
||
explain select * from t where a < 1; | ||
id count task operator info | ||
Selection_5 8000.00 root lt(test.t.a, 1) | ||
└─TableReader_7 10000.00 root data:TableScan_6 | ||
└─TableScan_6 10000.00 cop table:t, range:[-inf,+inf], keep order:false, stats:pseudo | ||
delete from mysql.opt_rule_blacklist where name='predicate_push_down'; | ||
admin reload opt_rule_blacklist; | ||
|
||
explain select * from t where a < 1; | ||
id count task operator info | ||
TableReader_7 3323.33 root data:Selection_6 | ||
└─Selection_6 3323.33 cop lt(test.t.a, 1) | ||
└─TableScan_5 10000.00 cop table:t, range:[-inf,+inf], keep order:false, stats:pseudo | ||
insert into mysql.expr_pushdown_blacklist values('lt'); | ||
admin reload expr_pushdown_blacklist; | ||
|
||
explain select * from t where a < 1; | ||
id count task operator info | ||
Selection_5 8000.00 root lt(test.t.a, 1) | ||
└─TableReader_7 10000.00 root data:TableScan_6 | ||
└─TableScan_6 10000.00 cop table:t, range:[-inf,+inf], keep order:false, stats:pseudo | ||
delete from mysql.expr_pushdown_blacklist where name='lt'; | ||
admin reload expr_pushdown_blacklist; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use test; | ||
drop table if exists t; | ||
create table t (a int); | ||
|
||
explain select * from t where a < 1; | ||
|
||
insert into mysql.opt_rule_blacklist values('predicate_push_down'); | ||
|
||
admin reload opt_rule_blacklist; | ||
|
||
explain select * from t where a < 1; | ||
|
||
delete from mysql.opt_rule_blacklist where name='predicate_push_down'; | ||
|
||
admin reload opt_rule_blacklist; | ||
|
||
explain select * from t where a < 1; | ||
|
||
insert into mysql.expr_pushdown_blacklist values('lt'); | ||
|
||
admin reload expr_pushdown_blacklist; | ||
|
||
explain select * from t where a < 1; | ||
|
||
delete from mysql.expr_pushdown_blacklist where name='lt'; | ||
|
||
admin reload expr_pushdown_blacklist; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2019 PingCAP, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package executor | ||
|
||
import ( | ||
"context" | ||
|
||
plannercore "github.com/pingcap/tidb/planner/core" | ||
"github.com/pingcap/tidb/sessionctx" | ||
"github.com/pingcap/tidb/util/chunk" | ||
"github.com/pingcap/tidb/util/set" | ||
"github.com/pingcap/tidb/util/sqlexec" | ||
) | ||
|
||
// ReloadOptRuleBlacklistExec indicates ReloadOptRuleBlacklist executor. | ||
type ReloadOptRuleBlacklistExec struct { | ||
baseExecutor | ||
} | ||
|
||
// Next implements the Executor Next interface. | ||
func (e *ReloadOptRuleBlacklistExec) Next(ctx context.Context, _ *chunk.Chunk) error { | ||
return LoadOptRuleBlacklist(e.ctx) | ||
} | ||
|
||
// LoadOptRuleBlacklist loads the latest data from table mysql.opt_rule_blacklist. | ||
func LoadOptRuleBlacklist(ctx sessionctx.Context) (err error) { | ||
sql := "select HIGH_PRIORITY name from mysql.opt_rule_blacklist" | ||
rows, _, err := ctx.(sqlexec.RestrictedSQLExecutor).ExecRestrictedSQL(ctx, sql) | ||
if err != nil { | ||
return err | ||
} | ||
newDisabledLogicalRules := set.NewStringSet() | ||
for _, row := range rows { | ||
name := row.GetString(0) | ||
newDisabledLogicalRules.Insert(name) | ||
} | ||
plannercore.DefaultDisabledLogicalRulesList.Store(newDisabledLogicalRules) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -218,3 +218,7 @@ func (ds *DataSource) buildKeyInfo() { | |
} | ||
} | ||
} | ||
|
||
func (*buildKeySolver) name() string { | ||
return "build_keys" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.