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
607aab9c
Commit
607aab9c
authored
Feb 16, 2012
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Counters for Index Condition Pushdown added (MDEV-130).
parent
764eeeee
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
181 additions
and
6 deletions
+181
-6
mysql-test/include/icp_tests.inc
mysql-test/include/icp_tests.inc
+22
-0
mysql-test/r/innodb_icp.result
mysql-test/r/innodb_icp.result
+27
-0
mysql-test/r/join_cache.result
mysql-test/r/join_cache.result
+17
-0
mysql-test/r/maria_icp.result
mysql-test/r/maria_icp.result
+27
-0
mysql-test/r/myisam_icp.result
mysql-test/r/myisam_icp.result
+27
-0
mysql-test/r/status.result
mysql-test/r/status.result
+5
-1
mysql-test/r/status_user.result
mysql-test/r/status_user.result
+2
-0
mysql-test/t/join_cache.test
mysql-test/t/join_cache.test
+5
-0
sql/mysqld.cc
sql/mysqld.cc
+2
-0
sql/sql_class.h
sql/sql_class.h
+2
-0
sql/sql_join_cache.cc
sql/sql_join_cache.cc
+20
-2
sql/sql_join_cache.h
sql/sql_join_cache.h
+2
-0
storage/maria/ha_maria.cc
storage/maria/ha_maria.cc
+7
-1
storage/myisam/ha_myisam.cc
storage/myisam/ha_myisam.cc
+7
-1
storage/xtradb/handler/ha_innodb.cc
storage/xtradb/handler/ha_innodb.cc
+7
-1
storage/xtradb/handler/ha_innodb.h
storage/xtradb/handler/ha_innodb.h
+2
-0
No files found.
mysql-test/include/icp_tests.inc
View file @
607aab9c
...
...
@@ -852,3 +852,25 @@ SET optimizer_switch=@save_optimizer_switch;
DROP
TABLE
t1
,
t2
;
--
echo
# check "Handler_pushed" status varuiables
CREATE
TABLE
t1
(
c1
CHAR
(
1
),
c2
CHAR
(
1
),
KEY
(
c1
)
);
INSERT
INTO
t1
VALUES
(
'3'
,
'3'
),(
'4'
,
'4'
),(
'5'
,
'5'
);
flush
status
;
show
status
like
"Handler_pushed%"
;
SELECT
*
FROM
t1
FORCE
INDEX
(
c1
)
WHERE
(
c1
=
'3'
or
c1
=
'4'
)
and
c1
%
2
=
0
;
show
status
like
"Handler_pushed%"
;
SELECT
*
FROM
t1
WHERE
(
c2
=
'3'
or
c2
=
'4'
)
and
c2
%
2
=
0
;
show
status
like
"Handler_pushed%"
;
DROP
TABLE
t1
;
mysql-test/r/innodb_icp.result
View file @
607aab9c
...
...
@@ -808,5 +808,32 @@ COUNT(*)
1478
SET optimizer_switch=@save_optimizer_switch;
DROP TABLE t1,t2;
# check "Handler_pushed" status varuiables
CREATE TABLE t1 (
c1 CHAR(1),
c2 CHAR(1),
KEY (c1)
);
INSERT INTO t1 VALUES ('3', '3'),('4','4'),('5','5');
flush status;
show status like "Handler_pushed%";
Variable_name Value
Handler_pushed_index_cond_checks 0
Handler_pushed_index_cond_filtered 0
SELECT * FROM t1 FORCE INDEX(c1) WHERE (c1='3' or c1='4') and c1 % 2 = 0 ;
c1 c2
4 4
show status like "Handler_pushed%";
Variable_name Value
Handler_pushed_index_cond_checks 2
Handler_pushed_index_cond_filtered 1
SELECT * FROM t1 WHERE (c2='3' or c2='4') and c2 % 2 = 0 ;
c1 c2
4 4
show status like "Handler_pushed%";
Variable_name Value
Handler_pushed_index_cond_checks 2
Handler_pushed_index_cond_filtered 1
DROP TABLE t1;
set optimizer_switch=@innodb_icp_tmp;
set storage_engine= @save_storage_engine;
mysql-test/r/join_cache.result
View file @
607aab9c
...
...
@@ -3506,6 +3506,7 @@ insert into t2 values (2,1, 'qwerty'),(2,2, 'qwerty'),(2,3, 'qwerty'),
insert into t2 values (3,1, 'qwerty'),(3,4, 'qwerty');
insert into t2 values (4,1, 'qwerty'),(4,2, 'qwerty'),(4,3, 'qwerty'),
(4,4, 'qwerty');
flush status;
set join_cache_level=5;
select t2.f1, t2.f2, t2.f3 from t1,t2
where t1.f1=t2.f1 and t2.f2 between t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1;
...
...
@@ -3519,6 +3520,10 @@ where t1.f1=t2.f1 and t2.f2 between t1.f1 and t2.f2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where
1 SIMPLE t2 ref f1 f1 4 test.t1.f1 3 Using index condition(BKA); Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
show status like "Handler_pushed%";
Variable_name Value
Handler_pushed_index_cond_checks 20
Handler_pushed_index_cond_filtered 16
set join_cache_level=6;
select t2.f1, t2.f2, t2.f3 from t1,t2
where t1.f1=t2.f1 and t2.f2 between t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1;
...
...
@@ -3532,6 +3537,10 @@ where t1.f1=t2.f1 and t2.f2 between t1.f1 and t2.f2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where
1 SIMPLE t2 ref f1 f1 4 test.t1.f1 3 Using index condition(BKA); Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan
show status like "Handler_pushed%";
Variable_name Value
Handler_pushed_index_cond_checks 40
Handler_pushed_index_cond_filtered 32
set join_cache_level=7;
select t2.f1, t2.f2, t2.f3 from t1,t2
where t1.f1=t2.f1 and t2.f2 between t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1;
...
...
@@ -3545,6 +3554,10 @@ where t1.f1=t2.f1 and t2.f2 between t1.f1 and t2.f2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where
1 SIMPLE t2 ref f1 f1 4 test.t1.f1 3 Using index condition(BKA); Using where; Using join buffer (flat, BKAH join); Key-ordered Rowid-ordered scan
show status like "Handler_pushed%";
Variable_name Value
Handler_pushed_index_cond_checks 60
Handler_pushed_index_cond_filtered 48
set join_cache_level=8;
select t2.f1, t2.f2, t2.f3 from t1,t2
where t1.f1=t2.f1 and t2.f2 between t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1;
...
...
@@ -3558,6 +3571,10 @@ where t1.f1=t2.f1 and t2.f2 between t1.f1 and t2.f2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where
1 SIMPLE t2 ref f1 f1 4 test.t1.f1 3 Using index condition(BKA); Using where; Using join buffer (flat, BKAH join); Key-ordered Rowid-ordered scan
show status like "Handler_pushed%";
Variable_name Value
Handler_pushed_index_cond_checks 80
Handler_pushed_index_cond_filtered 64
drop table t1,t2;
set join_cache_level=default;
#
...
...
mysql-test/r/maria_icp.result
View file @
607aab9c
...
...
@@ -814,5 +814,32 @@ COUNT(*)
1478
SET optimizer_switch=@save_optimizer_switch;
DROP TABLE t1,t2;
# check "Handler_pushed" status varuiables
CREATE TABLE t1 (
c1 CHAR(1),
c2 CHAR(1),
KEY (c1)
);
INSERT INTO t1 VALUES ('3', '3'),('4','4'),('5','5');
flush status;
show status like "Handler_pushed%";
Variable_name Value
Handler_pushed_index_cond_checks 0
Handler_pushed_index_cond_filtered 0
SELECT * FROM t1 FORCE INDEX(c1) WHERE (c1='3' or c1='4') and c1 % 2 = 0 ;
c1 c2
4 4
show status like "Handler_pushed%";
Variable_name Value
Handler_pushed_index_cond_checks 2
Handler_pushed_index_cond_filtered 1
SELECT * FROM t1 WHERE (c2='3' or c2='4') and c2 % 2 = 0 ;
c1 c2
4 4
show status like "Handler_pushed%";
Variable_name Value
Handler_pushed_index_cond_checks 2
Handler_pushed_index_cond_filtered 1
DROP TABLE t1;
set storage_engine= @save_storage_engine;
set optimizer_switch=@maria_icp_tmp;
mysql-test/r/myisam_icp.result
View file @
607aab9c
...
...
@@ -812,6 +812,33 @@ COUNT(*)
1478
SET optimizer_switch=@save_optimizer_switch;
DROP TABLE t1,t2;
# check "Handler_pushed" status varuiables
CREATE TABLE t1 (
c1 CHAR(1),
c2 CHAR(1),
KEY (c1)
);
INSERT INTO t1 VALUES ('3', '3'),('4','4'),('5','5');
flush status;
show status like "Handler_pushed%";
Variable_name Value
Handler_pushed_index_cond_checks 0
Handler_pushed_index_cond_filtered 0
SELECT * FROM t1 FORCE INDEX(c1) WHERE (c1='3' or c1='4') and c1 % 2 = 0 ;
c1 c2
4 4
show status like "Handler_pushed%";
Variable_name Value
Handler_pushed_index_cond_checks 2
Handler_pushed_index_cond_filtered 1
SELECT * FROM t1 WHERE (c2='3' or c2='4') and c2 % 2 = 0 ;
c1 c2
4 4
show status like "Handler_pushed%";
Variable_name Value
Handler_pushed_index_cond_checks 2
Handler_pushed_index_cond_filtered 1
DROP TABLE t1;
drop table if exists t0, t1, t1i, t1m;
#
# BUG#826935 Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed
...
...
mysql-test/r/status.result
View file @
607aab9c
...
...
@@ -276,6 +276,8 @@ Handler_commit 0
Handler_delete 0
Handler_discover 0
Handler_prepare 0
Handler_pushed_index_cond_checks 0
Handler_pushed_index_cond_filtered 0
Handler_read_first 0
Handler_read_key 4
Handler_read_next 0
...
...
@@ -297,7 +299,7 @@ Created_tmp_files 0
Created_tmp_tables 2
Handler_tmp_update 2
Handler_tmp_write 7
Rows_tmp_read 3
5
Rows_tmp_read 3
7
drop table t1;
CREATE TABLE t1 (i int(11) DEFAULT NULL, KEY i (i) ) ENGINE=MyISAM;
insert into t1 values (1),(2),(3),(4),(5);
...
...
@@ -311,6 +313,8 @@ Handler_commit 0
Handler_delete 0
Handler_discover 0
Handler_prepare 0
Handler_pushed_index_cond_checks 0
Handler_pushed_index_cond_filtered 0
Handler_read_first 0
Handler_read_key 2
Handler_read_next 2
...
...
mysql-test/r/status_user.result
View file @
607aab9c
...
...
@@ -101,6 +101,8 @@ Handler_commit 19
Handler_delete 1
Handler_discover 0
Handler_prepare 18
Handler_pushed_index_cond_checks 0
Handler_pushed_index_cond_filtered 0
Handler_read_first 0
Handler_read_key 3
Handler_read_next 0
...
...
mysql-test/t/join_cache.test
View file @
607aab9c
...
...
@@ -1526,12 +1526,14 @@ insert into t2 values (3,1, 'qwerty'),(3,4, 'qwerty');
insert
into
t2
values
(
4
,
1
,
'qwerty'
),(
4
,
2
,
'qwerty'
),(
4
,
3
,
'qwerty'
),
(
4
,
4
,
'qwerty'
);
flush
status
;
set
join_cache_level
=
5
;
select
t2
.
f1
,
t2
.
f2
,
t2
.
f3
from
t1
,
t2
where
t1
.
f1
=
t2
.
f1
and
t2
.
f2
between
t1
.
f1
and
t1
.
f2
and
t2
.
f2
+
1
>=
t1
.
f1
+
1
;
explain
select
t2
.
f1
,
t2
.
f2
,
t2
.
f3
from
t1
,
t2
where
t1
.
f1
=
t2
.
f1
and
t2
.
f2
between
t1
.
f1
and
t2
.
f2
;
show
status
like
"Handler_pushed%"
;
set
join_cache_level
=
6
;
select
t2
.
f1
,
t2
.
f2
,
t2
.
f3
from
t1
,
t2
...
...
@@ -1539,6 +1541,7 @@ where t1.f1=t2.f1 and t2.f2 between t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1;
explain
select
t2
.
f1
,
t2
.
f2
,
t2
.
f3
from
t1
,
t2
where
t1
.
f1
=
t2
.
f1
and
t2
.
f2
between
t1
.
f1
and
t2
.
f2
;
show
status
like
"Handler_pushed%"
;
set
join_cache_level
=
7
;
select
t2
.
f1
,
t2
.
f2
,
t2
.
f3
from
t1
,
t2
...
...
@@ -1546,6 +1549,7 @@ where t1.f1=t2.f1 and t2.f2 between t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1;
explain
select
t2
.
f1
,
t2
.
f2
,
t2
.
f3
from
t1
,
t2
where
t1
.
f1
=
t2
.
f1
and
t2
.
f2
between
t1
.
f1
and
t2
.
f2
;
show
status
like
"Handler_pushed%"
;
set
join_cache_level
=
8
;
select
t2
.
f1
,
t2
.
f2
,
t2
.
f3
from
t1
,
t2
...
...
@@ -1553,6 +1557,7 @@ where t1.f1=t2.f1 and t2.f2 between t1.f1 and t1.f2 and t2.f2 + 1 >= t1.f1 + 1;
explain
select
t2
.
f1
,
t2
.
f2
,
t2
.
f3
from
t1
,
t2
where
t1
.
f1
=
t2
.
f1
and
t2
.
f2
between
t1
.
f1
and
t2
.
f2
;
show
status
like
"Handler_pushed%"
;
drop
table
t1
,
t2
;
set
join_cache_level
=
default
;
...
...
sql/mysqld.cc
View file @
607aab9c
...
...
@@ -8291,6 +8291,8 @@ SHOW_VAR status_vars[]= {
{"Handler_mrr_init", (char*) offsetof(STATUS_VAR, ha_multi_range_read_init_count), SHOW_LONG_STATUS},
#endif
{
"Handler_prepare"
,
(
char
*
)
offsetof
(
STATUS_VAR
,
ha_prepare_count
),
SHOW_LONG_STATUS
},
{
"Handler_pushed_index_cond_checks"
,(
char
*
)
offsetof
(
STATUS_VAR
,
ha_pushed_index_cond_checks
),
SHOW_LONG_STATUS
},
{
"Handler_pushed_index_cond_filtered"
,(
char
*
)
offsetof
(
STATUS_VAR
,
ha_pushed_index_cond_filtered
),
SHOW_LONG_STATUS
},
{
"Handler_read_first"
,
(
char
*
)
offsetof
(
STATUS_VAR
,
ha_read_first_count
),
SHOW_LONG_STATUS
},
{
"Handler_read_key"
,
(
char
*
)
offsetof
(
STATUS_VAR
,
ha_read_key_count
),
SHOW_LONG_STATUS
},
{
"Handler_read_next"
,
(
char
*
)
offsetof
(
STATUS_VAR
,
ha_read_next_count
),
SHOW_LONG_STATUS
},
...
...
sql/sql_class.h
View file @
607aab9c
...
...
@@ -588,6 +588,8 @@ typedef struct system_status_var
ulong
ha_tmp_update_count
;
ulong
ha_tmp_write_count
;
ulong
ha_prepare_count
;
ulong
ha_pushed_index_cond_checks
;
ulong
ha_pushed_index_cond_filtered
;
ulong
ha_discover_count
;
ulong
ha_savepoint_count
;
ulong
ha_savepoint_rollback_count
;
...
...
sql/sql_join_cache.cc
View file @
607aab9c
...
...
@@ -2576,6 +2576,15 @@ void JOIN_CACHE::print_explain_comment(String *str)
str
->
append
(
STRING_WITH_LEN
(
")"
));
}
/**
get thread handle.
*/
THD
*
JOIN_CACHE
::
thd
()
{
return
join
->
thd
;
}
static
void
add_mrr_explain_info
(
String
*
str
,
uint
mrr_mode
,
handler
*
file
)
{
...
...
@@ -4015,7 +4024,11 @@ bool bka_skip_index_tuple(range_seq_t rseq, range_id_t range_info)
{
DBUG_ENTER
(
"bka_skip_index_tuple"
);
JOIN_CACHE_BKA
*
cache
=
(
JOIN_CACHE_BKA
*
)
rseq
;
bool
res
=
cache
->
skip_index_tuple
(
range_info
);
THD
*
thd
=
cache
->
thd
();
bool
res
;
status_var_increment
(
thd
->
status_var
.
ha_pushed_index_cond_checks
);
if
((
res
=
cache
->
skip_index_tuple
(
range_info
)))
status_var_increment
(
thd
->
status_var
.
ha_pushed_index_cond_filtered
);
DBUG_RETURN
(
res
);
}
...
...
@@ -4490,7 +4503,12 @@ bool bkah_skip_index_tuple(range_seq_t rseq, range_id_t range_info)
{
DBUG_ENTER
(
"bka_unique_skip_index_tuple"
);
JOIN_CACHE_BKAH
*
cache
=
(
JOIN_CACHE_BKAH
*
)
rseq
;
DBUG_RETURN
(
cache
->
skip_index_tuple
(
range_info
));
THD
*
thd
=
cache
->
thd
();
bool
res
;
status_var_increment
(
thd
->
status_var
.
ha_pushed_index_cond_checks
);
if
((
res
=
cache
->
skip_index_tuple
(
range_info
)))
status_var_increment
(
thd
->
status_var
.
ha_pushed_index_cond_filtered
);
DBUG_RETURN
(
res
);
}
...
...
sql/sql_join_cache.h
View file @
607aab9c
...
...
@@ -643,6 +643,8 @@ class JOIN_CACHE :public Sql_alloc
/* Add a comment on the join algorithm employed by the join cache */
virtual
void
print_explain_comment
(
String
*
str
);
THD
*
thd
();
virtual
~
JOIN_CACHE
()
{}
void
reset_join
(
JOIN
*
j
)
{
join
=
j
;
}
void
free
()
...
...
storage/maria/ha_maria.cc
View file @
607aab9c
...
...
@@ -2248,12 +2248,18 @@ C_MODE_START
ICP_RESULT
index_cond_func_maria
(
void
*
arg
)
{
ha_maria
*
h
=
(
ha_maria
*
)
arg
;
THD
*
thd
=
((
TABLE
*
)
h
->
file
->
external_ref
)
->
in_use
;
ICP_RESULT
res
;
if
(
h
->
end_range
)
{
if
(
h
->
compare_key2
(
h
->
end_range
)
>
0
)
return
ICP_OUT_OF_RANGE
;
/* caller should return HA_ERR_END_OF_FILE already */
}
return
h
->
pushed_idx_cond
->
val_int
()
?
ICP_MATCH
:
ICP_NO_MATCH
;
status_var_increment
(
thd
->
status_var
.
ha_pushed_index_cond_checks
);
if
((
res
=
h
->
pushed_idx_cond
->
val_int
()
?
ICP_MATCH
:
ICP_NO_MATCH
)
==
ICP_NO_MATCH
)
status_var_increment
(
thd
->
status_var
.
ha_pushed_index_cond_filtered
);
return
res
;
}
C_MODE_END
...
...
storage/myisam/ha_myisam.cc
View file @
607aab9c
...
...
@@ -1770,12 +1770,18 @@ C_MODE_START
ICP_RESULT
index_cond_func_myisam
(
void
*
arg
)
{
ha_myisam
*
h
=
(
ha_myisam
*
)
arg
;
THD
*
thd
=
((
TABLE
*
)
h
->
file
->
external_ref
)
->
in_use
;
ICP_RESULT
res
;
if
(
h
->
end_range
)
{
if
(
h
->
compare_key2
(
h
->
end_range
)
>
0
)
return
ICP_OUT_OF_RANGE
;
/* caller should return HA_ERR_END_OF_FILE already */
}
return
(
ICP_RESULT
)
test
(
h
->
pushed_idx_cond
->
val_int
());
status_var_increment
(
thd
->
status_var
.
ha_pushed_index_cond_checks
);
if
((
res
=
(
ICP_RESULT
)
test
(
h
->
pushed_idx_cond
->
val_int
()))
==
ICP_NO_MATCH
)
status_var_increment
(
thd
->
status_var
.
ha_pushed_index_cond_filtered
);
return
res
;
}
C_MODE_END
...
...
storage/xtradb/handler/ha_innodb.cc
View file @
607aab9c
...
...
@@ -12583,6 +12583,8 @@ innobase_index_cond(
void
*
file
)
/*!< in/out: pointer to ha_innobase */
{
ha_innobase
*
h
=
(
ha_innobase
*
)
file
;
THD
*
thd
=
h
->
thd
();
enum
icp_result
res
;
if
(
h
->
is_thd_killed
())
return
ICP_ABORTED_BY_USER
;
...
...
@@ -12592,7 +12594,11 @@ innobase_index_cond(
if
(
h
->
compare_key2
(
h
->
end_range
)
>
0
)
return
ICP_OUT_OF_RANGE
;
/* caller should return HA_ERR_END_OF_FILE already */
}
return
h
->
pushed_idx_cond
->
val_int
()
?
ICP_MATCH
:
ICP_NO_MATCH
;
status_var_increment
(
thd
->
status_var
.
ha_pushed_index_cond_checks
);
if
((
res
=
h
->
pushed_idx_cond
->
val_int
()
?
ICP_MATCH
:
ICP_NO_MATCH
)
==
ICP_NO_MATCH
)
status_var_increment
(
thd
->
status_var
.
ha_pushed_index_cond_filtered
);
return
res
;
}
/** Attempt to push down an index condition.
...
...
storage/xtradb/handler/ha_innodb.h
View file @
607aab9c
...
...
@@ -223,6 +223,8 @@ class ha_innobase: public handler
bool
check_if_incompatible_data
(
HA_CREATE_INFO
*
info
,
uint
table_changes
);
bool
check_if_supported_virtual_columns
(
void
)
{
return
TRUE
;
}
THD
*
thd
()
{
return
user_thd
;
}
private:
/** Builds a 'template' to the prebuilt struct.
...
...
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