Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
16e5bc4c
Commit
16e5bc4c
authored
May 04, 2023
by
Oleksandr Byelkin
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '10.9' into 10.10
parents
13a294a2
d7fae797
Changes
17
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
1636 additions
and
355 deletions
+1636
-355
mysql-test/main/derived_split_innodb.result
mysql-test/main/derived_split_innodb.result
+537
-0
mysql-test/main/derived_split_innodb.test
mysql-test/main/derived_split_innodb.test
+212
-0
mysql-test/main/explain_innodb.result
mysql-test/main/explain_innodb.result
+18
-0
mysql-test/main/explain_innodb.test
mysql-test/main/explain_innodb.test
+19
-0
mysql-test/main/opt_trace.result
mysql-test/main/opt_trace.result
+184
-66
mysql-test/main/opt_trace.test
mysql-test/main/opt_trace.test
+70
-7
mysql-test/main/selectivity.result
mysql-test/main/selectivity.result
+0
-69
mysql-test/main/selectivity.test
mysql-test/main/selectivity.test
+3
-81
mysql-test/main/selectivity_innodb.result
mysql-test/main/selectivity_innodb.result
+0
-69
mysql-test/main/selectivity_innodb_notembedded.result
mysql-test/main/selectivity_innodb_notembedded.result
+104
-0
mysql-test/main/selectivity_innodb_notembedded.test
mysql-test/main/selectivity_innodb_notembedded.test
+16
-0
mysql-test/main/selectivity_notembedded.result
mysql-test/main/selectivity_notembedded.result
+95
-0
mysql-test/main/selectivity_notembedded.test
mysql-test/main/selectivity_notembedded.test
+121
-0
sql/item_subselect.cc
sql/item_subselect.cc
+6
-0
sql/opt_split.cc
sql/opt_split.cc
+187
-53
sql/sql_select.cc
sql/sql_select.cc
+36
-7
sql/sql_select.h
sql/sql_select.h
+28
-3
No files found.
mysql-test/main/derived_split_innodb.result
View file @
16e5bc4c
This diff is collapsed.
Click to expand it.
mysql-test/main/derived_split_innodb.test
View file @
16e5bc4c
...
...
@@ -233,4 +233,216 @@ drop table t3, t4;
--
echo
# End of 10.3 tests
--
echo
#
--
echo
# MDEV-26301: Split optimization refills temporary table too many times
--
echo
#
# 5 values
create
table
t1
(
a
int
,
b
int
);
insert
into
t1
select
seq
,
seq
from
seq_1_to_5
;
# 5 value groups of size 2 each
create
table
t2
(
a
int
,
b
int
,
key
(
a
));
insert
into
t2
select
A
.
seq
,
B
.
seq
from
seq_1_to_25
A
,
seq_1_to_2
B
;
# 5 value groups of size 3 each
create
table
t3
(
a
int
,
b
int
,
key
(
a
));
insert
into
t3
select
A
.
seq
,
B
.
seq
from
seq_1_to_5
A
,
seq_1_to_3
B
;
analyze
table
t1
,
t2
,
t3
persistent
for
all
;
explain
select
*
from
(
t1
left
join
t2
on
t2
.
a
=
t1
.
b
)
left
join
t3
on
t3
.
a
=
t1
.
b
;
# Now, create tables for Groups.
create
table
t10
(
grp_id
int
,
col1
int
,
key
(
grp_id
)
);
# 100 groups of 100 values each
insert
into
t10
select
A
.
seq
,
B
.
seq
from
seq_1_to_100
A
,
seq_1_to_100
B
;
# and X10 multiplier
create
table
t11
(
col1
int
,
col2
int
);
insert
into
t11
select
A
.
seq
,
A
.
seq
from
seq_1_to_10
A
;
analyze
table
t10
,
t11
persistent
for
all
;
let
$q1
=
select
*
from
(
(
t1
left
join
t2
on
t2
.
a
=
t1
.
b
)
left
join
t3
on
t3
.
a
=
t1
.
b
)
left
join
(
select
grp_id
,
count
(
*
)
from
t10
left
join
t11
on
t11
.
col1
=
t10
.
col1
group
by
grp_id
)
T
on
T
.
grp_id
=
t1
.
b
;
eval
explain
$q1
;
--
echo
# The important part in the below output is:
--
echo
# "lateral": 1,
--
echo
# "query_block": {
--
echo
# "select_id": 2,
--
echo
# "r_loops": 5, <-- must be 5, not 30.
--
source
include
/
analyze
-
format
.
inc
eval
analyze
format
=
json
$q1
;
create
table
t21
(
pk
int
primary
key
);
insert
into
t21
values
(
1
),(
2
),(
3
);
create
table
t22
(
pk
int
primary
key
);
insert
into
t22
values
(
1
),(
2
),(
3
);
# Same as above but throw in a couple of const tables.
explain
select
*
from
t21
,
t22
,
(
(
t1
left
join
t2
on
t2
.
a
=
t1
.
b
)
left
join
t3
on
t3
.
a
=
t1
.
b
)
left
join
(
select
grp_id
,
count
(
*
)
from
t10
left
join
t11
on
t11
.
col1
=
t10
.
col1
group
by
grp_id
)
T
on
T
.
grp_id
=
t1
.
b
where
t21
.
pk
=
1
and
t22
.
pk
=
2
;
explain
select
*
from
t21
,
(
(
t1
left
join
t2
on
t2
.
a
=
t1
.
b
)
left
join
t3
on
t3
.
a
=
t1
.
b
)
left
join
(
select
grp_id
,
count
(
*
)
from
t22
join
t10
left
join
t11
on
t11
.
col1
=
t10
.
col1
where
t22
.
pk
=
1
group
by
grp_id
)
T
on
T
.
grp_id
=
t1
.
b
where
t21
.
pk
=
1
;
# And also add a non-const table
create
table
t5
(
pk
int
primary
key
);
insert
into
t5
select
seq
from
seq_1_to_1000
;
explain
select
*
from
t21
,
(
(((
t1
join
t5
on
t5
.
pk
=
t1
.
b
))
left
join
t2
on
t2
.
a
=
t1
.
b
)
left
join
t3
on
t3
.
a
=
t1
.
b
)
left
join
(
select
grp_id
,
count
(
*
)
from
t22
join
t10
left
join
t11
on
t11
.
col1
=
t10
.
col1
where
t22
.
pk
=
1
group
by
grp_id
)
T
on
T
.
grp_id
=
t1
.
b
where
t21
.
pk
=
1
;
drop
table
t1
,
t2
,
t3
,
t5
,
t10
,
t11
,
t21
,
t22
;
# 5 values
create
table
t1
(
a
int
,
b
int
);
insert
into
t1
select
seq
,
seq
from
seq_1_to_5
;
# 5 value groups of size 2 each
create
table
t2
(
a
int
,
b
int
,
key
(
a
));
insert
into
t2
select
A
.
seq
,
B
.
seq
from
seq_1_to_25
A
,
seq_1_to_2
B
;
# 5 value groups of size 3 each
create
table
t3
(
a
int
,
b
int
,
key
(
a
));
insert
into
t3
select
A
.
seq
,
B
.
seq
from
seq_1_to_5
A
,
seq_1_to_3
B
;
analyze
table
t1
,
t2
,
t3
persistent
for
all
;
create
table
t10
(
grp_id
int
,
col1
int
,
key
(
grp_id
)
);
# 100 groups of 100 values each
insert
into
t10
select
A
.
seq
,
B
.
seq
from
seq_1_to_100
A
,
seq_1_to_100
B
;
# and X10 multiplier
create
table
t11
(
col1
int
,
col2
int
);
insert
into
t11
select
A
.
seq
,
A
.
seq
from
seq_1_to_10
A
;
analyze
table
t10
,
t11
persistent
for
all
;
let
$q
=
select
*
from
(
(
t1
left
join
t2
on
t2
.
a
=
t1
.
b
)
left
join
t3
on
t3
.
a
=
t1
.
b
)
left
join
(
select
grp_id
,
count
(
*
)
from
t10
left
join
t11
on
t11
.
col1
=
t10
.
col1
group
by
grp_id
)
dt
on
dt
.
grp_id
=
t1
.
b
;
eval
explain
$q
;
eval
$q
;
set
join_cache_level
=
4
;
eval
explain
$q
;
eval
$q
;
set
join_cache_level
=
default
;
drop
index
a
on
t2
;
drop
index
a
on
t3
;
eval
explain
$q
;
eval
$q
;
drop
table
t1
,
t2
,
t3
;
drop
table
t10
,
t11
;
--
echo
# End of 10.4 tests
SET
GLOBAL
innodb_stats_persistent
=@
save_innodb_stats_persistent
;
mysql-test/main/explain_innodb.result
View file @
16e5bc4c
...
...
@@ -18,3 +18,21 @@ id select_type table type possible_keys key key_len ref rows Extra
2 DERIVED t1 range NULL id 53 NULL 2 Using index for group-by
SET GLOBAL slow_query_log = @sql_tmp;
drop table t1;
#
# MDEV-31181: Server crash in subselect_uniquesubquery_engine::print
# upon EXPLAIN EXTENDED DELETE
#
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (pk INT PRIMARY KEY);
INSERT INTO t2 VALUES (1),(2);
EXPLAIN EXTENDED DELETE FROM t1 WHERE a IN (SELECT pk FROM t2);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where
2 DEPENDENT SUBQUERY t2 unique_subquery PRIMARY PRIMARY 4 func 1 100.00 Using index
Warnings:
Note 1003 /* select#1 */ delete from `test`.`t1` where <in_optimizer>(`test`.`t1`.`a`,<exists>(<primary_index_lookup>(<cache>(`test`.`t1`.`a`))))
drop table t1, t2;
#
# End of 10.4 tests
#
mysql-test/main/explain_innodb.test
View file @
16e5bc4c
...
...
@@ -18,3 +18,22 @@ SELECT * FROM (SELECT id FROM t1 GROUP BY id) dt WHERE 1=0;
SET
GLOBAL
slow_query_log
=
@
sql_tmp
;
drop
table
t1
;
--
echo
#
--
echo
# MDEV-31181: Server crash in subselect_uniquesubquery_engine::print
--
echo
# upon EXPLAIN EXTENDED DELETE
--
echo
#
CREATE
TABLE
t1
(
a
INT
);
INSERT
INTO
t1
VALUES
(
1
),(
2
);
CREATE
TABLE
t2
(
pk
INT
PRIMARY
KEY
);
INSERT
INTO
t2
VALUES
(
1
),(
2
);
EXPLAIN
EXTENDED
DELETE
FROM
t1
WHERE
a
IN
(
SELECT
pk
FROM
t2
);
drop
table
t1
,
t2
;
--
echo
#
--
echo
# End of 10.4 tests
--
echo
#
mysql-test/main/opt_trace.result
View file @
16e5bc4c
...
...
@@ -480,6 +480,11 @@ select * from v2 {
}
]
},
{
"check_split_materialized": {
"not_applicable": "no candidate field can be accessed through ref"
}
},
{
"best_join_order": ["t1"]
},
...
...
@@ -827,6 +832,11 @@ explain select * from v1 {
}
]
},
{
"check_split_materialized": {
"not_applicable": "group list has no candidates"
}
},
{
"best_join_order": ["t1"]
},
...
...
@@ -10343,6 +10353,110 @@ SET optimizer_trace=DEFAULT;
DROP VIEW v;
DROP TABLE t;
#
# MDEV-26301: Split optimization improvements: Optimizer Trace coverage
#
create table t1(a int, b int);
insert into t1 select seq,seq from seq_1_to_5;
create table t2(a int, b int, key(a));
insert into t2
select A.seq,B.seq from seq_1_to_25 A, seq_1_to_2 B;
create table t3(a int, b int, key(a));
insert into t3
select A.seq,B.seq from seq_1_to_5 A, seq_1_to_3 B;
analyze table t1,t2,t3 persistent for all;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
test.t2 analyze status Engine-independent statistics collected
test.t2 analyze status Table is already up to date
test.t3 analyze status Engine-independent statistics collected
test.t3 analyze status Table is already up to date
create table t10 (
grp_id int,
col1 int,
key(grp_id)
);
insert into t10
select
A.seq,
B.seq
from
seq_1_to_100 A,
seq_1_to_100 B;
create table t11 (
col1 int,
col2 int
);
insert into t11
select A.seq, A.seq from seq_1_to_10 A;
analyze table t10,t11 persistent for all;
Table Op Msg_type Msg_text
test.t10 analyze status Engine-independent statistics collected
test.t10 analyze status Table is already up to date
test.t11 analyze status Engine-independent statistics collected
test.t11 analyze status OK
set optimizer_trace=1;
explain
select * from
(
(t1 left join t2 on t2.a=t1.b)
left join t3 on t3.a=t1.b
) left join (select grp_id, count(*)
from t10 left join t11 on t11.col1=t10.col1
group by grp_id) T on T.grp_id=t1.b;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 5
1 PRIMARY t2 ref a a 5 test.t1.b 2 Using where
1 PRIMARY t3 ref a a 5 test.t1.b 3 Using where
1 PRIMARY <derived2> ref key0 key0 5 test.t1.b 10 Using where
2 LATERAL DERIVED t10 ref grp_id grp_id 5 test.t1.b 100
2 LATERAL DERIVED t11 ALL NULL NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join)
select json_detailed(json_extract(trace, '$**.check_split_materialized')) as JS
from information_schema.optimizer_trace;
JS
[
{
"split_candidates":
["t10.grp_id"]
}
]
select
json_detailed(
json_remove(
json_extract(trace, '$**.choose_best_splitting')
, '$[0].split_plan_search[0]'
)
) as JS
from information_schema.optimizer_trace;
JS
[
{
"considered_keys":
[
{
"table_name": "t10",
"index": "grp_id",
"rec_per_key": 100,
"param_tables": 1
}
],
"refills": 5,
"spl_pd_boundary": 2,
"split_plan_search":
[],
"lead_table": "t10",
"index": "grp_id",
"parts": 1,
"split_sel": 0.001,
"cost": 2535.968504,
"unsplit_cost": 253440.0075,
"records": 100,
"chosen": true
}
]
drop table t1,t2,t3,t10,t11;
set optimizer_trace=DEFAULT;
#
# End of 10.4 tests
#
set optimizer_trace='enabled=on';
...
...
@@ -10763,79 +10877,83 @@ from
information_schema.optimizer_trace;
json_detailed(json_extract(trace, '$**.choose_best_splitting'))
[
[
{
"considered_execution_plans":
[
{
"plan_prefix":
[],
"get_costs_for_tables":
[
{
"best_access_path":
{
"considered_keys":
[]
},
{
"considered_keys":
[
{
"table_name": "t2",
"index": "idx_a",
"rec_per_key": 1.8367,
"param_tables": 1
}
],
"refills": 4,
"spl_pd_boundary": 2,
"split_plan_search":
[
{
"considered_execution_plans":
[
{
"plan_prefix":
[],
"get_costs_for_tables":
[
{
"table": "t2",
"considered_access_paths":
[
"best_access_path":
{
"table": "t2",
"considered_access_paths":
[
{
"access_type": "ref",
"index": "idx_a",
"used_range_estimates": false,
"reason": "not available",
"rows": 1.8367,
"cost": 2.000585794,
"chosen": true
},
{
"type": "scan",
"chosen": false,
"cause": "cost"
}
],
"chosen_access_method":
{
"access_type": "ref",
"index": "idx_a",
"used_range_estimates": false,
"reason": "not available",
"rows": 1.8367,
"type": "ref",
"records": 1.8367,
"cost": 2.000585794,
"chosen": true
},
{
"type": "scan",
"chosen": false,
"cause": "cost"
"uses_join_buffering": false
}
],
"chosen_access_method":
{
"type": "ref",
"records": 1.8367,
"cost": 2.000585794,
"uses_join_buffering": false
}
}
}
]
},
{
"plan_prefix":
[],
"table": "t2",
"rows_for_plan": 1.8367,
"cost_for_plan": 2.367925794,
"cost_for_sorting": 1.8367
}
]
},
{
"best_splitting":
{
"table": "t2",
"key": "idx_a",
"record_count": 4,
"cost": 2.488945919,
"unsplit_cost": 25.72361682
]
},
{
"plan_prefix":
[],
"table": "t2",
"rows_for_plan": 1.8367,
"cost_for_plan": 2.367925794,
"cost_for_sorting": 1.8367
}
]
}
}
]
]
select
json_detailed(json_extract(trace, '$**.lateral_derived'))
from
information_schema.optimizer_trace;
json_detailed(json_extract(trace, '$**.lateral_derived'))
[
{
"startup_cost": 9.955783677,
"splitting_cost": 2.488945919,
"records": 1
],
"lead_table": "t2",
"index": "idx_a",
"parts": 1,
"split_sel": 0.020407778,
"cost": 2.488945919,
"unsplit_cost": 25.72361682,
"records": 1,
"chosen": true
}
]
drop table t1,t2;
...
...
mysql-test/main/opt_trace.test
View file @
16e5bc4c
...
...
@@ -701,6 +701,76 @@ SET optimizer_trace=DEFAULT;
DROP
VIEW
v
;
DROP
TABLE
t
;
--
echo
#
--
echo
# MDEV-26301: Split optimization improvements: Optimizer Trace coverage
--
echo
#
# 5 values
create
table
t1
(
a
int
,
b
int
);
insert
into
t1
select
seq
,
seq
from
seq_1_to_5
;
# 5 value groups of size 2 each
create
table
t2
(
a
int
,
b
int
,
key
(
a
));
insert
into
t2
select
A
.
seq
,
B
.
seq
from
seq_1_to_25
A
,
seq_1_to_2
B
;
# 5 value groups of size 3 each
create
table
t3
(
a
int
,
b
int
,
key
(
a
));
insert
into
t3
select
A
.
seq
,
B
.
seq
from
seq_1_to_5
A
,
seq_1_to_3
B
;
analyze
table
t1
,
t2
,
t3
persistent
for
all
;
create
table
t10
(
grp_id
int
,
col1
int
,
key
(
grp_id
)
);
# 100 groups of 100 values each
insert
into
t10
select
A
.
seq
,
B
.
seq
from
seq_1_to_100
A
,
seq_1_to_100
B
;
# and X10 multiplier
create
table
t11
(
col1
int
,
col2
int
);
insert
into
t11
select
A
.
seq
,
A
.
seq
from
seq_1_to_10
A
;
analyze
table
t10
,
t11
persistent
for
all
;
set
optimizer_trace
=
1
;
explain
select
*
from
(
(
t1
left
join
t2
on
t2
.
a
=
t1
.
b
)
left
join
t3
on
t3
.
a
=
t1
.
b
)
left
join
(
select
grp_id
,
count
(
*
)
from
t10
left
join
t11
on
t11
.
col1
=
t10
.
col1
group
by
grp_id
)
T
on
T
.
grp_id
=
t1
.
b
;
select
json_detailed
(
json_extract
(
trace
,
'$**.check_split_materialized'
))
as
JS
from
information_schema
.
optimizer_trace
;
select
json_detailed
(
json_remove
(
json_extract
(
trace
,
'$**.choose_best_splitting'
)
,
'$[0].split_plan_search[0]'
)
)
as
JS
from
information_schema
.
optimizer_trace
;
drop
table
t1
,
t2
,
t3
,
t10
,
t11
;
set
optimizer_trace
=
DEFAULT
;
--
echo
#
--
echo
# End of 10.4 tests
--
echo
#
...
...
@@ -909,13 +979,6 @@ from
information_schema
.
optimizer_trace
;
--
enable_view_protocol
# Same as above. just to show that splitting plan has some coverage in the
# trace.
select
json_detailed
(
json_extract
(
trace
,
'$**.lateral_derived'
))
from
information_schema
.
optimizer_trace
;
drop
table
t1
,
t2
;
--
echo
#
...
...
mysql-test/main/selectivity.result
View file @
16e5bc4c
...
...
@@ -1943,75 +1943,6 @@ Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 2
DROP TABLE t1;
# End of 10.2 tests
#
# MDEV-31067: selectivity_from_histogram >1.0 for a DOUBLE_PREC_HB histogram
#
create table t0(a int);
insert into t0 select 1 from seq_1_to_78;
create table t1(a int);
insert into t1 select 1 from seq_1_to_26;
create table t10 (a int);
insert into t10 select 0 from t0, seq_1_to_4;
insert into t10 select 8693 from t1;
insert into t10 select 8694 from t1;
insert into t10 select 8695 from t1;
insert into t10 select 34783 from t1;
insert into t10 select 34784 from t1;
insert into t10 select 34785 from t1;
insert into t10 select 34785 from t0, seq_1_to_8;
insert into t10 select 65214 from t1;
insert into t10 select 65215 from t1;
insert into t10 select 65216 from t1;
insert into t10 select 65216 from t0, seq_1_to_52;
insert into t10 select 65217 from t1;
insert into t10 select 65218 from t1;
insert into t10 select 65219 from t1;
insert into t10 select 65219 from t0;
insert into t10 select 73913 from t1;
insert into t10 select 73914 from t1;
insert into t10 select 73915 from t1;
insert into t10 select 73915 from t0, seq_1_to_40;
insert into t10 select 78257 from t1;
insert into t10 select 78258 from t1;
insert into t10 select 78259 from t1;
insert into t10 select 91300 from t1;
insert into t10 select 91301 from t1;
insert into t10 select 91302 from t1;
insert into t10 select 91302 from t0, seq_1_to_6;
insert into t10 select 91303 from t1;
insert into t10 select 91304 from t1;
insert into t10 select 91305 from t1;
insert into t10 select 91305 from t0, seq_1_to_8;
insert into t10 select 99998 from t1;
insert into t10 select 99999 from t1;
insert into t10 select 100000 from t1;
set use_stat_tables=preferably;
analyze table t10 persistent for all;
Table Op Msg_type Msg_text
test.t10 analyze status Engine-independent statistics collected
test.t10 analyze status OK
flush tables;
set @tmp=@@optimizer_trace;
set optimizer_trace=1;
explain select * from t10 where a in (91303);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t10 ALL NULL NULL NULL NULL 9984 Using where
# Must have selectivity_from_histogram <= 1.0:
select json_detailed(json_extract(trace, '$**.selectivity_for_columns'))
from information_schema.optimizer_trace;
json_detailed(json_extract(trace, '$**.selectivity_for_columns'))
[
[
{
"column_name": "a",
"ranges":
["91303 <= a <= 91303"],
"selectivity_from_histogram": 0.035714283
}
]
]
set optimizer_trace=@tmp;
drop table t0,t1,t10;
set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
set histogram_size=@save_histogram_size;
set use_stat_tables= @save_use_stat_tables;
...
...
mysql-test/main/selectivity.test
View file @
16e5bc4c
...
...
@@ -1326,90 +1326,12 @@ DROP TABLE t1;
--
echo
# End of 10.2 tests
--
echo
#
--
echo
# MDEV-31067: selectivity_from_histogram >1.0 for a DOUBLE_PREC_HB histogram
--
echo
#
create
table
t0
(
a
int
);
# This holds how many rows we hold in a bucket.
insert
into
t0
select
1
from
seq_1_to_78
;
create
table
t1
(
a
int
);
# one-third of a bucket
insert
into
t1
select
1
from
seq_1_to_26
;
create
table
t10
(
a
int
);
insert
into
t10
select
0
from
t0
,
seq_1_to_4
;
insert
into
t10
select
8693
from
t1
;
insert
into
t10
select
8694
from
t1
;
insert
into
t10
select
8695
from
t1
;
insert
into
t10
select
34783
from
t1
;
insert
into
t10
select
34784
from
t1
;
insert
into
t10
select
34785
from
t1
;
insert
into
t10
select
34785
from
t0
,
seq_1_to_8
;
insert
into
t10
select
65214
from
t1
;
insert
into
t10
select
65215
from
t1
;
insert
into
t10
select
65216
from
t1
;
insert
into
t10
select
65216
from
t0
,
seq_1_to_52
;
insert
into
t10
select
65217
from
t1
;
insert
into
t10
select
65218
from
t1
;
insert
into
t10
select
65219
from
t1
;
insert
into
t10
select
65219
from
t0
;
insert
into
t10
select
73913
from
t1
;
insert
into
t10
select
73914
from
t1
;
insert
into
t10
select
73915
from
t1
;
insert
into
t10
select
73915
from
t0
,
seq_1_to_40
;
insert
into
t10
select
78257
from
t1
;
insert
into
t10
select
78258
from
t1
;
insert
into
t10
select
78259
from
t1
;
insert
into
t10
select
91300
from
t1
;
insert
into
t10
select
91301
from
t1
;
insert
into
t10
select
91302
from
t1
;
insert
into
t10
select
91302
from
t0
,
seq_1_to_6
;
insert
into
t10
select
91303
from
t1
;
# Only 1/3rd of bucket matches the search tuple
insert
into
t10
select
91304
from
t1
;
insert
into
t10
select
91305
from
t1
;
insert
into
t10
select
91305
from
t0
,
seq_1_to_8
;
insert
into
t10
select
99998
from
t1
;
insert
into
t10
select
99999
from
t1
;
insert
into
t10
select
100000
from
t1
;
set
use_stat_tables
=
preferably
;
analyze
table
t10
persistent
for
all
;
flush
tables
;
set
@
tmp
=@@
optimizer_trace
;
set
optimizer_trace
=
1
;
explain
select
*
from
t10
where
a
in
(
91303
);
--
echo
# Must have selectivity_from_histogram <= 1.0:
select
json_detailed
(
json_extract
(
trace
,
'$**.selectivity_for_columns'
))
from
information_schema
.
optimizer_trace
;
set
optimizer_trace
=@
tmp
;
drop
table
t0
,
t1
,
t10
;
set
optimizer_use_condition_selectivity
=
@
save_optimizer_use_condition_selectivity
;
set
histogram_size
=@
save_histogram_size
;
set
use_stat_tables
=
@
save_use_stat_tables
;
#
# Clean up
#
set
optimizer_use_condition_selectivity
=
@
save_optimizer_use_condition_selectivity
;
set
histogram_size
=@
save_histogram_size
;
set
use_stat_tables
=
@
save_use_stat_tables
;
--
source
include
/
restore_charset
.
inc
set
@@
global
.
histogram_size
=@
save_histogram_size
;
mysql-test/main/selectivity_innodb.result
View file @
16e5bc4c
...
...
@@ -1955,75 +1955,6 @@ Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 2
DROP TABLE t1;
# End of 10.2 tests
#
# MDEV-31067: selectivity_from_histogram >1.0 for a DOUBLE_PREC_HB histogram
#
create table t0(a int);
insert into t0 select 1 from seq_1_to_78;
create table t1(a int);
insert into t1 select 1 from seq_1_to_26;
create table t10 (a int);
insert into t10 select 0 from t0, seq_1_to_4;
insert into t10 select 8693 from t1;
insert into t10 select 8694 from t1;
insert into t10 select 8695 from t1;
insert into t10 select 34783 from t1;
insert into t10 select 34784 from t1;
insert into t10 select 34785 from t1;
insert into t10 select 34785 from t0, seq_1_to_8;
insert into t10 select 65214 from t1;
insert into t10 select 65215 from t1;
insert into t10 select 65216 from t1;
insert into t10 select 65216 from t0, seq_1_to_52;
insert into t10 select 65217 from t1;
insert into t10 select 65218 from t1;
insert into t10 select 65219 from t1;
insert into t10 select 65219 from t0;
insert into t10 select 73913 from t1;
insert into t10 select 73914 from t1;
insert into t10 select 73915 from t1;
insert into t10 select 73915 from t0, seq_1_to_40;
insert into t10 select 78257 from t1;
insert into t10 select 78258 from t1;
insert into t10 select 78259 from t1;
insert into t10 select 91300 from t1;
insert into t10 select 91301 from t1;
insert into t10 select 91302 from t1;
insert into t10 select 91302 from t0, seq_1_to_6;
insert into t10 select 91303 from t1;
insert into t10 select 91304 from t1;
insert into t10 select 91305 from t1;
insert into t10 select 91305 from t0, seq_1_to_8;
insert into t10 select 99998 from t1;
insert into t10 select 99999 from t1;
insert into t10 select 100000 from t1;
set use_stat_tables=preferably;
analyze table t10 persistent for all;
Table Op Msg_type Msg_text
test.t10 analyze status Engine-independent statistics collected
test.t10 analyze status OK
flush tables;
set @tmp=@@optimizer_trace;
set optimizer_trace=1;
explain select * from t10 where a in (91303);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t10 ALL NULL NULL NULL NULL 9984 Using where
# Must have selectivity_from_histogram <= 1.0:
select json_detailed(json_extract(trace, '$**.selectivity_for_columns'))
from information_schema.optimizer_trace;
json_detailed(json_extract(trace, '$**.selectivity_for_columns'))
[
[
{
"column_name": "a",
"ranges":
["91303 <= a <= 91303"],
"selectivity_from_histogram": 0.035714283
}
]
]
set optimizer_trace=@tmp;
drop table t0,t1,t10;
set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
set histogram_size=@save_histogram_size;
set use_stat_tables= @save_use_stat_tables;
...
...
mysql-test/main/selectivity_innodb_notembedded.result
0 → 100644
View file @
16e5bc4c
SET SESSION STORAGE_ENGINE='InnoDB';
Warnings:
Warning 1287 '@@storage_engine' is deprecated and will be removed in a future release. Please use '@@default_storage_engine' instead
set @save_optimizer_switch_for_selectivity_test=@@optimizer_switch;
set optimizer_switch='extended_keys=on';
drop table if exists t0,t1,t2,t3;
select @@global.use_stat_tables;
@@global.use_stat_tables
COMPLEMENTARY
select @@session.use_stat_tables;
@@session.use_stat_tables
COMPLEMENTARY
set @save_use_stat_tables=@@use_stat_tables;
set use_stat_tables='preferably';
set @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity;
set @save_histogram_size=@@histogram_size;
set @save_histogram_type=@@histogram_type;
set join_cache_level=2;
set @@global.histogram_size=0,@@local.histogram_size=0;
set histogram_type='single_prec_hb';
set optimizer_use_condition_selectivity=3;
#
# MDEV-31067: selectivity_from_histogram >1.0 for a DOUBLE_PREC_HB histogram
#
create table t0(a int);
insert into t0 select 1 from seq_1_to_78;
create table t1(a int);
insert into t1 select 1 from seq_1_to_26;
create table t10 (a int);
insert into t10 select 0 from t0, seq_1_to_4;
insert into t10 select 8693 from t1;
insert into t10 select 8694 from t1;
insert into t10 select 8695 from t1;
insert into t10 select 34783 from t1;
insert into t10 select 34784 from t1;
insert into t10 select 34785 from t1;
insert into t10 select 34785 from t0, seq_1_to_8;
insert into t10 select 65214 from t1;
insert into t10 select 65215 from t1;
insert into t10 select 65216 from t1;
insert into t10 select 65216 from t0, seq_1_to_52;
insert into t10 select 65217 from t1;
insert into t10 select 65218 from t1;
insert into t10 select 65219 from t1;
insert into t10 select 65219 from t0;
insert into t10 select 73913 from t1;
insert into t10 select 73914 from t1;
insert into t10 select 73915 from t1;
insert into t10 select 73915 from t0, seq_1_to_40;
insert into t10 select 78257 from t1;
insert into t10 select 78258 from t1;
insert into t10 select 78259 from t1;
insert into t10 select 91300 from t1;
insert into t10 select 91301 from t1;
insert into t10 select 91302 from t1;
insert into t10 select 91302 from t0, seq_1_to_6;
insert into t10 select 91303 from t1;
insert into t10 select 91304 from t1;
insert into t10 select 91305 from t1;
insert into t10 select 91305 from t0, seq_1_to_8;
insert into t10 select 99998 from t1;
insert into t10 select 99999 from t1;
insert into t10 select 100000 from t1;
set use_stat_tables=preferably;
analyze table t10 persistent for all;
Table Op Msg_type Msg_text
test.t10 analyze status Engine-independent statistics collected
test.t10 analyze status OK
flush tables;
set @tmp=@@optimizer_trace;
set optimizer_trace=1;
explain select * from t10 where a in (91303);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t10 ALL NULL NULL NULL NULL 9984 Using where
# Must have selectivity_from_histogram <= 1.0:
select json_detailed(json_extract(trace, '$**.selectivity_for_columns')) as sel
from information_schema.optimizer_trace;
sel
[
[
{
"column_name": "a",
"ranges":
["91303 <= a <= 91303"],
"selectivity_from_histogram": 0.035714283
}
]
]
set optimizer_trace=@tmp;
drop table t0,t1,t10;
set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
set histogram_size=@save_histogram_size;
set use_stat_tables= @save_use_stat_tables;
#
# End of 10.4 tests
#
#
# Clean up
#
set @@global.histogram_size=@save_histogram_size;
set optimizer_switch=@save_optimizer_switch_for_selectivity_test;
SET SESSION STORAGE_ENGINE=DEFAULT;
Warnings:
Warning 1287 '@@storage_engine' is deprecated and will be removed in a future release. Please use '@@default_storage_engine' instead
mysql-test/main/selectivity_innodb_notembedded.test
0 → 100644
View file @
16e5bc4c
--
source
include
/
have_innodb
.
inc
# This test is slow on buildbot.
--
source
include
/
big_test
.
inc
--
source
include
/
default_optimizer_switch
.
inc
--
source
include
/
not_embedded
.
inc
SET
SESSION
STORAGE_ENGINE
=
'InnoDB'
;
set
@
save_optimizer_switch_for_selectivity_test
=@@
optimizer_switch
;
set
optimizer_switch
=
'extended_keys=on'
;
--
source
selectivity_notembedded
.
test
set
optimizer_switch
=@
save_optimizer_switch_for_selectivity_test
;
SET
SESSION
STORAGE_ENGINE
=
DEFAULT
;
mysql-test/main/selectivity_notembedded.result
0 → 100644
View file @
16e5bc4c
drop table if exists t0,t1,t2,t3;
select @@global.use_stat_tables;
@@global.use_stat_tables
COMPLEMENTARY
select @@session.use_stat_tables;
@@session.use_stat_tables
COMPLEMENTARY
set @save_use_stat_tables=@@use_stat_tables;
set use_stat_tables='preferably';
set @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity;
set @save_histogram_size=@@histogram_size;
set @save_histogram_type=@@histogram_type;
set join_cache_level=2;
set @@global.histogram_size=0,@@local.histogram_size=0;
set histogram_type='single_prec_hb';
set optimizer_use_condition_selectivity=3;
#
# MDEV-31067: selectivity_from_histogram >1.0 for a DOUBLE_PREC_HB histogram
#
create table t0(a int);
insert into t0 select 1 from seq_1_to_78;
create table t1(a int);
insert into t1 select 1 from seq_1_to_26;
create table t10 (a int);
insert into t10 select 0 from t0, seq_1_to_4;
insert into t10 select 8693 from t1;
insert into t10 select 8694 from t1;
insert into t10 select 8695 from t1;
insert into t10 select 34783 from t1;
insert into t10 select 34784 from t1;
insert into t10 select 34785 from t1;
insert into t10 select 34785 from t0, seq_1_to_8;
insert into t10 select 65214 from t1;
insert into t10 select 65215 from t1;
insert into t10 select 65216 from t1;
insert into t10 select 65216 from t0, seq_1_to_52;
insert into t10 select 65217 from t1;
insert into t10 select 65218 from t1;
insert into t10 select 65219 from t1;
insert into t10 select 65219 from t0;
insert into t10 select 73913 from t1;
insert into t10 select 73914 from t1;
insert into t10 select 73915 from t1;
insert into t10 select 73915 from t0, seq_1_to_40;
insert into t10 select 78257 from t1;
insert into t10 select 78258 from t1;
insert into t10 select 78259 from t1;
insert into t10 select 91300 from t1;
insert into t10 select 91301 from t1;
insert into t10 select 91302 from t1;
insert into t10 select 91302 from t0, seq_1_to_6;
insert into t10 select 91303 from t1;
insert into t10 select 91304 from t1;
insert into t10 select 91305 from t1;
insert into t10 select 91305 from t0, seq_1_to_8;
insert into t10 select 99998 from t1;
insert into t10 select 99999 from t1;
insert into t10 select 100000 from t1;
set use_stat_tables=preferably;
analyze table t10 persistent for all;
Table Op Msg_type Msg_text
test.t10 analyze status Engine-independent statistics collected
test.t10 analyze status OK
flush tables;
set @tmp=@@optimizer_trace;
set optimizer_trace=1;
explain select * from t10 where a in (91303);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t10 ALL NULL NULL NULL NULL 9984 Using where
# Must have selectivity_from_histogram <= 1.0:
select json_detailed(json_extract(trace, '$**.selectivity_for_columns')) as sel
from information_schema.optimizer_trace;
sel
[
[
{
"column_name": "a",
"ranges":
["91303 <= a <= 91303"],
"selectivity_from_histogram": 0.035714283
}
]
]
set optimizer_trace=@tmp;
drop table t0,t1,t10;
set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
set histogram_size=@save_histogram_size;
set use_stat_tables= @save_use_stat_tables;
#
# End of 10.4 tests
#
#
# Clean up
#
set @@global.histogram_size=@save_histogram_size;
mysql-test/main/selectivity_notembedded.test
0 → 100644
View file @
16e5bc4c
--
source
include
/
no_valgrind_without_big
.
inc
--
source
include
/
have_stat_tables
.
inc
--
source
include
/
have_sequence
.
inc
--
source
include
/
default_charset
.
inc
--
source
include
/
not_embedded
.
inc
--
disable_warnings
drop
table
if
exists
t0
,
t1
,
t2
,
t3
;
--
enable_warnings
select
@@
global
.
use_stat_tables
;
select
@@
session
.
use_stat_tables
;
set
@
save_use_stat_tables
=@@
use_stat_tables
;
set
use_stat_tables
=
'preferably'
;
--
source
include
/
default_optimizer_switch
.
inc
set
@
save_optimizer_use_condition_selectivity
=@@
optimizer_use_condition_selectivity
;
set
@
save_histogram_size
=@@
histogram_size
;
set
@
save_histogram_type
=@@
histogram_type
;
set
join_cache_level
=
2
;
set
@@
global
.
histogram_size
=
0
,
@@
local
.
histogram_size
=
0
;
set
histogram_type
=
'single_prec_hb'
;
# check that statistics on nulls is used
set
optimizer_use_condition_selectivity
=
3
;
--
echo
#
--
echo
# MDEV-31067: selectivity_from_histogram >1.0 for a DOUBLE_PREC_HB histogram
--
echo
#
create
table
t0
(
a
int
);
# This holds how many rows we hold in a bucket.
insert
into
t0
select
1
from
seq_1_to_78
;
create
table
t1
(
a
int
);
# one-third of a bucket
insert
into
t1
select
1
from
seq_1_to_26
;
create
table
t10
(
a
int
);
insert
into
t10
select
0
from
t0
,
seq_1_to_4
;
insert
into
t10
select
8693
from
t1
;
insert
into
t10
select
8694
from
t1
;
insert
into
t10
select
8695
from
t1
;
insert
into
t10
select
34783
from
t1
;
insert
into
t10
select
34784
from
t1
;
insert
into
t10
select
34785
from
t1
;
insert
into
t10
select
34785
from
t0
,
seq_1_to_8
;
insert
into
t10
select
65214
from
t1
;
insert
into
t10
select
65215
from
t1
;
insert
into
t10
select
65216
from
t1
;
insert
into
t10
select
65216
from
t0
,
seq_1_to_52
;
insert
into
t10
select
65217
from
t1
;
insert
into
t10
select
65218
from
t1
;
insert
into
t10
select
65219
from
t1
;
insert
into
t10
select
65219
from
t0
;
insert
into
t10
select
73913
from
t1
;
insert
into
t10
select
73914
from
t1
;
insert
into
t10
select
73915
from
t1
;
insert
into
t10
select
73915
from
t0
,
seq_1_to_40
;
insert
into
t10
select
78257
from
t1
;
insert
into
t10
select
78258
from
t1
;
insert
into
t10
select
78259
from
t1
;
insert
into
t10
select
91300
from
t1
;
insert
into
t10
select
91301
from
t1
;
insert
into
t10
select
91302
from
t1
;
insert
into
t10
select
91302
from
t0
,
seq_1_to_6
;
insert
into
t10
select
91303
from
t1
;
# Only 1/3rd of bucket matches the search tuple
insert
into
t10
select
91304
from
t1
;
insert
into
t10
select
91305
from
t1
;
insert
into
t10
select
91305
from
t0
,
seq_1_to_8
;
insert
into
t10
select
99998
from
t1
;
insert
into
t10
select
99999
from
t1
;
insert
into
t10
select
100000
from
t1
;
set
use_stat_tables
=
preferably
;
analyze
table
t10
persistent
for
all
;
flush
tables
;
set
@
tmp
=@@
optimizer_trace
;
set
optimizer_trace
=
1
;
explain
select
*
from
t10
where
a
in
(
91303
);
--
echo
# Must have selectivity_from_histogram <= 1.0:
select
json_detailed
(
json_extract
(
trace
,
'$**.selectivity_for_columns'
))
as
sel
from
information_schema
.
optimizer_trace
;
set
optimizer_trace
=@
tmp
;
drop
table
t0
,
t1
,
t10
;
set
optimizer_use_condition_selectivity
=
@
save_optimizer_use_condition_selectivity
;
set
histogram_size
=@
save_histogram_size
;
set
use_stat_tables
=
@
save_use_stat_tables
;
--
echo
#
--
echo
# End of 10.4 tests
--
echo
#
--
echo
#
--
echo
# Clean up
--
echo
#
--
source
include
/
restore_charset
.
inc
set
@@
global
.
histogram_size
=@
save_histogram_size
;
sql/item_subselect.cc
View file @
16e5bc4c
...
...
@@ -4624,6 +4624,12 @@ void subselect_uniquesubquery_engine::print(String *str,
{
str
->
append
(
STRING_WITH_LEN
(
"<primary_index_lookup>("
));
tab
->
ref
.
items
[
0
]
->
print
(
str
,
query_type
);
if
(
!
tab
->
table
)
{
// table is not opened so unknown
str
->
append
(
')'
);
return
;
}
str
->
append
(
STRING_WITH_LEN
(
" in "
));
if
(
tab
->
table
->
s
->
table_category
==
TABLE_CATEGORY_TEMPORARY
)
{
...
...
sql/opt_split.cc
View file @
16e5bc4c
This diff is collapsed.
Click to expand it.
sql/sql_select.cc
View file @
16e5bc4c
...
...
@@ -7684,6 +7684,7 @@ void set_position(JOIN *join,uint idx,JOIN_TAB *table,KEYUSE *key)
join->positions[idx].records_read=1.0; /* This is a const table */
join->positions[idx].cond_selectivity= 1.0;
join->positions[idx].ref_depend_map= 0;
join->positions[idx].partial_join_cardinality= 1;
// join->positions[idx].loosescan_key= MAX_KEY; /* Not a LooseScan */
join->positions[idx].sj_strategy= SJ_OPT_NONE;
...
...
@@ -7701,6 +7702,7 @@ void set_position(JOIN *join,uint idx,JOIN_TAB *table,KEYUSE *key)
}
join->best_ref[idx]=table;
join->positions[idx].spl_plan= 0;
join->positions[idx].spl_pd_boundary= 0;
}
...
...
@@ -7987,6 +7989,7 @@ best_access_path(JOIN *join,
MY_BITMAP *eq_join_set= &s->table->eq_join_set;
KEYUSE *hj_start_key= 0;
SplM_plan_info *spl_plan= 0;
table_map spl_pd_boundary= 0;
Range_rowid_filter_cost_info *filter= 0;
const char* cause= NULL;
enum join_type best_type= JT_UNKNOWN, type= JT_UNKNOWN;
...
...
@@ -8005,9 +8008,11 @@ best_access_path(JOIN *join,
loose_scan_opt.init(join, s, remaining_tables);
if (s->table->is_splittable())
spl_plan= s->choose_best_splitting(record_count, remaining_tables);
Json_writer_array trace_paths(thd, "considered_access_paths");
spl_plan= s->choose_best_splitting(idx,
remaining_tables,
&spl_pd_boundary);
Json_writer_array trace_paths(thd, "considered_access_paths");
if (s->keyuse)
{ /* Use key if possible */
KEYUSE *keyuse;
...
...
@@ -8892,8 +8897,9 @@ best_access_path(JOIN *join,
best_filter= filter;
/* range/index_merge/ALL/index access method are "independent", so: */
best_ref_depends_map= 0;
best_uses_jbuf= MY_TEST(!disable_jbuf && !((s->table->map &
join->outer_join)));
best_uses_jbuf= MY_TEST(!disable_jbuf &&
(join->allowed_outer_join_with_cache ||
!(s->table->map & join->outer_join)));
spl_plan= 0;
best_type= type;
}
...
...
@@ -8916,6 +8922,7 @@ best_access_path(JOIN *join,
pos->loosescan_picker.loosescan_key= MAX_KEY;
pos->use_join_buffer= best_uses_jbuf;
pos->spl_plan= spl_plan;
pos->spl_pd_boundary= !spl_plan ? 0 : spl_pd_boundary;
pos->range_rowid_filter_info= best_filter;
pos->key_dependent= (best_type == JT_EQ_REF ? (table_map) 0 :
key_dependent & remaining_tables);
...
...
@@ -9449,6 +9456,9 @@ optimize_straight_join(JOIN *join, table_map remaining_tables)
pushdown_cond_selectivity= table_cond_selectivity(join, idx, s,
remaining_tables);
position->cond_selectivity= pushdown_cond_selectivity;
double partial_join_cardinality= record_count *
pushdown_cond_selectivity;
join->positions[idx].partial_join_cardinality= partial_join_cardinality;
++idx;
}
...
...
@@ -10784,8 +10794,10 @@ best_extension_by_limited_search(JOIN *join,
}
}
if ((search_depth > 1) &&
((remaining_tables & ~real_table_bit) & allowed_tables))
join->positions[idx].partial_join_cardinality= partial_join_cardinality;
if ((search_depth > 1) && (remaining_tables & ~real_table_bit) &
allowed_tables)
{
/* Recursively expand the current partial plan */
Json_writer_array trace_rest(thd, "rest_of_plan");
...
...
@@ -13850,6 +13862,9 @@ uint check_join_cache_usage(JOIN_TAB *tab,
join->return_tab= 0;
if (tab->no_forced_join_cache)
return 0;
/*
Don't use join cache if @@join_cache_level==0 or this table is the first
one join suborder (either at top level or inside a bush)
...
...
@@ -14818,7 +14833,8 @@ bool JOIN_TAB::preread_init()
DBUG_RETURN(TRUE);
if (!(derived->get_unit()->uncacheable & UNCACHEABLE_DEPENDENT) ||
derived->is_nonrecursive_derived_with_rec_ref())
derived->is_nonrecursive_derived_with_rec_ref() ||
is_split_derived)
preread_init_done= TRUE;
if (select && select->quick)
select->quick->replace_handler(table->file);
...
...
@@ -18396,6 +18412,9 @@ void optimize_wo_join_buffering(JOIN *join, uint first_tab, uint last_tab,
reopt_remaining_tables &
~real_table_bit);
}
double partial_join_cardinality= rec_count *
pushdown_cond_selectivity;
join->positions[i].partial_join_cardinality= partial_join_cardinality;
(*outer_rec_count) *= pushdown_cond_selectivity;
if (!rs->emb_sj_nest)
*outer_rec_count= COST_MULT(*outer_rec_count, pos.records_read);
...
...
@@ -22010,6 +22029,16 @@ sub_select(JOIN *join,JOIN_TAB *join_tab,bool end_of_records)
{
DBUG_ENTER("sub_select");
if (join_tab->split_derived_to_update && !end_of_records)
{
table_map tab_map= join_tab->split_derived_to_update;
for (uint i= 0; tab_map; i++, tab_map>>= 1)
{
if (tab_map & 1)
join->map2table[i]->preread_init_done= false;
}
}
if (join_tab->last_inner)
{
JOIN_TAB *last_inner_tab= join_tab->last_inner;
sql/sql_select.h
View file @
16e5bc4c
...
...
@@ -405,6 +405,8 @@ typedef struct st_join_table {
*/
bool
idx_cond_fact_out
;
bool
use_join_cache
;
/* TRUE <=> it is prohibited to join this table using join buffer */
bool
no_forced_join_cache
;
uint
used_join_cache_level
;
ulong
join_buffer_size_limit
;
JOIN_CACHE
*
cache
;
...
...
@@ -531,6 +533,16 @@ typedef struct st_join_table {
bool
preread_init_done
;
/* true <=> split optimization has been applied to this materialized table */
bool
is_split_derived
;
/*
Bitmap of split materialized derived tables that can be filled just before
this join table is to be joined. All parameters of the split derived tables
belong to tables preceding this join table.
*/
table_map
split_derived_to_update
;
/*
Cost info to the range filter used when joining this join table
(Defined when the best join order has been already chosen)
...
...
@@ -693,9 +705,10 @@ typedef struct st_join_table {
void
partial_cleanup
();
void
add_keyuses_for_splitting
();
SplM_plan_info
*
choose_best_splitting
(
double
record_count
,
table_map
remaining_tables
);
bool
fix_splitting
(
SplM_plan_info
*
spl_plan
,
table_map
remaining_tables
,
SplM_plan_info
*
choose_best_splitting
(
uint
idx
,
table_map
remaining_tables
,
table_map
*
spl_pd_boundary
);
bool
fix_splitting
(
SplM_plan_info
*
spl_plan
,
table_map
excluded_tables
,
bool
is_const_table
);
}
JOIN_TAB
;
...
...
@@ -963,9 +976,21 @@ class POSITION
*/
KEYUSE
*
key
;
/* Cardinality of current partial join ending with this position */
double
partial_join_cardinality
;
/* Info on splitting plan used at this position */
SplM_plan_info
*
spl_plan
;
/*
If spl_plan is NULL the value of spl_pd_boundary is 0. Otherwise
spl_pd_boundary contains the bitmap of the table from the current
partial join ending at this position that starts the sub-sequence of
tables S from which no conditions are allowed to be used in the plan
spl_plan for the split table joined at this position.
*/
table_map
spl_pd_boundary
;
/* Cost info for the range filter used at this position */
Range_rowid_filter_cost_info
*
range_rowid_filter_info
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment