-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
planner: update some UTs from cost model1 to model2 #39124
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d6f46db
fixup
qw4990 aa7e4af
fixup
qw4990 b7e2aef
fixup
qw4990 a1bd96d
fixup
qw4990 39ce002
fixup
qw4990 ad29c23
Merge branch 'master' into model2-ut
qw4990 2196118
Merge branch 'master' into model2-ut
fzzf678 d4653b5
Merge branch 'master' into model2-ut
hawkingrei File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -2880,6 +2880,7 @@ func TestBitColumnPushDown(t *testing.T) { | |
store := testkit.CreateMockStore(t) | ||
tk := testkit.NewTestKit(t, store) | ||
tk.MustExec("use test") | ||
tk.MustExec("set tidb_cost_model_version=1") | ||
tk.MustExec("create table t1(a bit(8), b int)") | ||
tk.MustExec("create table t2(a bit(8), b int)") | ||
tk.MustExec("insert into t1 values ('1', 1), ('2', 2), ('3', 3), ('4', 4), ('1', 1), ('2', 2), ('3', 3), ('4', 4)") | ||
|
@@ -5693,6 +5694,7 @@ func TestIndexJoinCost(t *testing.T) { | |
store := testkit.CreateMockStore(t) | ||
tk := testkit.NewTestKit(t, store) | ||
tk.MustExec("use test") | ||
tk.MustExec("set tidb_cost_model_version=2") | ||
tk.MustExec(`drop table if exists t_outer, t_inner_pk, t_inner_idx`) | ||
tk.MustExec(`create table t_outer (a int)`) | ||
tk.MustExec(`create table t_inner_pk (a int primary key)`) | ||
|
@@ -5702,46 +5704,46 @@ func TestIndexJoinCost(t *testing.T) { | |
tk.MustExec("set @@tidb_enable_chunk_rpc = on") | ||
|
||
tk.MustQuery(`explain format=verbose select /*+ TIDB_INLJ(t_outer, t_inner_pk) */ * from t_outer, t_inner_pk where t_outer.a=t_inner_pk.a`).Check(testkit.Rows( // IndexJoin with inner TableScan | ||
`IndexJoin_11 12487.50 206368.09 root inner join, inner:TableReader_8, outer key:test.t_outer.a, inner key:test.t_inner_pk.a, equal cond:eq(test.t_outer.a, test.t_inner_pk.a)`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Expected, just update cost values. |
||
`├─TableReader_18(Build) 9990.00 36412.58 root data:Selection_17`, | ||
`│ └─Selection_17 9990.00 465000.00 cop[tikv] not(isnull(test.t_outer.a))`, | ||
`│ └─TableFullScan_16 10000.00 435000.00 cop[tikv] table:t_outer keep order:false, stats:pseudo`, | ||
`└─TableReader_8(Probe) 9990.00 3.88 root data:TableRangeScan_7`, | ||
` └─TableRangeScan_7 9990.00 30.00 cop[tikv] table:t_inner_pk range: decided by [test.t_outer.a], keep order:false, stats:pseudo`)) | ||
`IndexJoin_11 12487.50 11918182.35 root inner join, inner:TableReader_8, outer key:test.t_outer.a, inner key:test.t_inner_pk.a, equal cond:eq(test.t_outer.a, test.t_inner_pk.a)`, | ||
`├─TableReader_18(Build) 9990.00 211131.09 root data:Selection_17`, | ||
`│ └─Selection_17 9990.00 2534000.00 cop[tikv] not(isnull(test.t_outer.a))`, | ||
`│ └─TableFullScan_16 10000.00 2035000.00 cop[tikv] table:t_outer keep order:false, stats:pseudo`, | ||
`└─TableReader_8(Probe) 9990.00 10.25 root data:TableRangeScan_7`, | ||
` └─TableRangeScan_7 9990.00 122.10 cop[tikv] table:t_inner_pk range: decided by [test.t_outer.a], keep order:false, stats:pseudo`)) | ||
tk.MustQuery(`explain format=verbose select /*+ TIDB_INLJ(t_outer, t_inner_idx) */ t_inner_idx.a from t_outer, t_inner_idx where t_outer.a=t_inner_idx.a`).Check(testkit.Rows( // IndexJoin with inner IndexScan | ||
`IndexJoin_10 12487.50 235192.19 root inner join, inner:IndexReader_9, outer key:test.t_outer.a, inner key:test.t_inner_idx.a, equal cond:eq(test.t_outer.a, test.t_inner_idx.a)`, | ||
`├─TableReader_20(Build) 9990.00 36412.58 root data:Selection_19`, | ||
`│ └─Selection_19 9990.00 465000.00 cop[tikv] not(isnull(test.t_outer.a))`, | ||
`│ └─TableFullScan_18 10000.00 435000.00 cop[tikv] table:t_outer keep order:false, stats:pseudo`, | ||
`└─IndexReader_9(Probe) 12487.50 5.89 root index:Selection_8`, | ||
` └─Selection_8 12487.50 58.18 cop[tikv] not(isnull(test.t_inner_idx.a))`, | ||
` └─IndexRangeScan_7 12500.00 54.43 cop[tikv] table:t_inner_idx, index:a(a) range: decided by [eq(test.t_inner_idx.a, test.t_outer.a)], keep order:false, stats:pseudo`)) | ||
`IndexJoin_10 12487.50 11918207.26 root inner join, inner:IndexReader_9, outer key:test.t_outer.a, inner key:test.t_inner_idx.a, equal cond:eq(test.t_outer.a, test.t_inner_idx.a)`, | ||
`├─TableReader_20(Build) 9990.00 211131.09 root data:Selection_19`, | ||
`│ └─Selection_19 9990.00 2534000.00 cop[tikv] not(isnull(test.t_outer.a))`, | ||
`│ └─TableFullScan_18 10000.00 2035000.00 cop[tikv] table:t_outer keep order:false, stats:pseudo`, | ||
`└─IndexReader_9(Probe) 12487.50 23.02 root index:Selection_8`, | ||
` └─Selection_8 12487.50 266.14 cop[tikv] not(isnull(test.t_inner_idx.a))`, | ||
` └─IndexRangeScan_7 12500.00 203.70 cop[tikv] table:t_inner_idx, index:a(a) range: decided by [eq(test.t_inner_idx.a, test.t_outer.a)], keep order:false, stats:pseudo`)) | ||
tk.MustQuery(`explain format=verbose select /*+ TIDB_INLJ(t_outer, t_inner_idx) */ * from t_outer, t_inner_idx where t_outer.a=t_inner_idx.a`).Check(testkit.Rows( // IndexJoin with inner IndexLookup | ||
`IndexJoin_11 12487.50 531469.38 root inner join, inner:IndexLookUp_10, outer key:test.t_outer.a, inner key:test.t_inner_idx.a, equal cond:eq(test.t_outer.a, test.t_inner_idx.a)`, | ||
`├─TableReader_23(Build) 9990.00 36412.58 root data:Selection_22`, | ||
`│ └─Selection_22 9990.00 465000.00 cop[tikv] not(isnull(test.t_outer.a))`, | ||
`│ └─TableFullScan_21 10000.00 435000.00 cop[tikv] table:t_outer keep order:false, stats:pseudo`, | ||
`└─IndexLookUp_10(Probe) 12487.50 35.55 root `, | ||
` ├─Selection_9(Build) 12487.50 75.08 cop[tikv] not(isnull(test.t_inner_idx.a))`, | ||
` │ └─IndexRangeScan_7 12500.00 71.32 cop[tikv] table:t_inner_idx, index:a(a) range: decided by [eq(test.t_inner_idx.a, test.t_outer.a)], keep order:false, stats:pseudo`, | ||
` └─TableRowIDScan_8(Probe) 12487.50 71.25 cop[tikv] table:t_inner_idx keep order:false, stats:pseudo`)) | ||
`IndexJoin_11 12487.50 11922930.69 root inner join, inner:IndexLookUp_10, outer key:test.t_outer.a, inner key:test.t_inner_idx.a, equal cond:eq(test.t_outer.a, test.t_inner_idx.a)`, | ||
`├─TableReader_23(Build) 9990.00 211131.09 root data:Selection_22`, | ||
`│ └─Selection_22 9990.00 2534000.00 cop[tikv] not(isnull(test.t_outer.a))`, | ||
`│ └─TableFullScan_21 10000.00 2035000.00 cop[tikv] table:t_outer keep order:false, stats:pseudo`, | ||
`└─IndexLookUp_10(Probe) 12487.50 2443.84 root `, | ||
` ├─Selection_9(Build) 12487.50 317.07 cop[tikv] not(isnull(test.t_inner_idx.a))`, | ||
` │ └─IndexRangeScan_7 12500.00 254.63 cop[tikv] table:t_inner_idx, index:a(a) range: decided by [eq(test.t_inner_idx.a, test.t_outer.a)], keep order:false, stats:pseudo`, | ||
` └─TableRowIDScan_8(Probe) 12487.50 284.13 cop[tikv] table:t_inner_idx keep order:false, stats:pseudo`)) | ||
|
||
tk.MustQuery("explain format=verbose select /*+ inl_hash_join(t_outer, t_inner_idx) */ t_inner_idx.a from t_outer, t_inner_idx where t_outer.a=t_inner_idx.a").Check(testkit.Rows( | ||
`IndexHashJoin_12 12487.50 235192.19 root inner join, inner:IndexReader_9, outer key:test.t_outer.a, inner key:test.t_inner_idx.a, equal cond:eq(test.t_outer.a, test.t_inner_idx.a)`, | ||
`├─TableReader_20(Build) 9990.00 36412.58 root data:Selection_19`, | ||
`│ └─Selection_19 9990.00 465000.00 cop[tikv] not(isnull(test.t_outer.a))`, | ||
`│ └─TableFullScan_18 10000.00 435000.00 cop[tikv] table:t_outer keep order:false, stats:pseudo`, | ||
`└─IndexReader_9(Probe) 12487.50 5.89 root index:Selection_8`, | ||
` └─Selection_8 12487.50 58.18 cop[tikv] not(isnull(test.t_inner_idx.a))`, | ||
` └─IndexRangeScan_7 12500.00 54.43 cop[tikv] table:t_inner_idx, index:a(a) range: decided by [eq(test.t_inner_idx.a, test.t_outer.a)], keep order:false, stats:pseudo`)) | ||
`IndexHashJoin_12 12487.50 11918207.26 root inner join, inner:IndexReader_9, outer key:test.t_outer.a, inner key:test.t_inner_idx.a, equal cond:eq(test.t_outer.a, test.t_inner_idx.a)`, | ||
`├─TableReader_20(Build) 9990.00 211131.09 root data:Selection_19`, | ||
`│ └─Selection_19 9990.00 2534000.00 cop[tikv] not(isnull(test.t_outer.a))`, | ||
`│ └─TableFullScan_18 10000.00 2035000.00 cop[tikv] table:t_outer keep order:false, stats:pseudo`, | ||
`└─IndexReader_9(Probe) 12487.50 23.02 root index:Selection_8`, | ||
` └─Selection_8 12487.50 266.14 cop[tikv] not(isnull(test.t_inner_idx.a))`, | ||
` └─IndexRangeScan_7 12500.00 203.70 cop[tikv] table:t_inner_idx, index:a(a) range: decided by [eq(test.t_inner_idx.a, test.t_outer.a)], keep order:false, stats:pseudo`)) | ||
tk.MustQuery("explain format=verbose select /*+ inl_merge_join(t_outer, t_inner_idx) */ t_inner_idx.a from t_outer, t_inner_idx where t_outer.a=t_inner_idx.a").Check(testkit.Rows( | ||
`IndexMergeJoin_17 12487.50 229210.68 root inner join, inner:IndexReader_15, outer key:test.t_outer.a, inner key:test.t_inner_idx.a`, | ||
`├─TableReader_20(Build) 9990.00 36412.58 root data:Selection_19`, | ||
`│ └─Selection_19 9990.00 465000.00 cop[tikv] not(isnull(test.t_outer.a))`, | ||
`│ └─TableFullScan_18 10000.00 435000.00 cop[tikv] table:t_outer keep order:false, stats:pseudo`, | ||
`└─IndexReader_15(Probe) 12487.50 5.89 root index:Selection_14`, | ||
` └─Selection_14 12487.50 58.18 cop[tikv] not(isnull(test.t_inner_idx.a))`, | ||
` └─IndexRangeScan_13 12500.00 54.43 cop[tikv] table:t_inner_idx, index:a(a) range: decided by [eq(test.t_inner_idx.a, test.t_outer.a)], keep order:true, stats:pseudo`)) | ||
`IndexMergeJoin_17 12487.50 11918207.26 root inner join, inner:IndexReader_15, outer key:test.t_outer.a, inner key:test.t_inner_idx.a`, | ||
`├─TableReader_20(Build) 9990.00 211131.09 root data:Selection_19`, | ||
`│ └─Selection_19 9990.00 2534000.00 cop[tikv] not(isnull(test.t_outer.a))`, | ||
`│ └─TableFullScan_18 10000.00 2035000.00 cop[tikv] table:t_outer keep order:false, stats:pseudo`, | ||
`└─IndexReader_15(Probe) 12487.50 23.02 root index:Selection_14`, | ||
` └─Selection_14 12487.50 266.14 cop[tikv] not(isnull(test.t_inner_idx.a))`, | ||
` └─IndexRangeScan_13 12500.00 203.70 cop[tikv] table:t_inner_idx, index:a(a) range: decided by [eq(test.t_inner_idx.a, test.t_outer.a)], keep order:true, stats:pseudo`)) | ||
} | ||
|
||
func TestHeuristicIndexSelection(t *testing.T) { | ||
|
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected, model2 prefers to use HashAgg.