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
f2d603c2
Commit
f2d603c2
authored
Dec 29, 2005
by
sergefp@mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WL#2985 "Partition Pruning": post-review fixes: Better comments
parent
328f8fa7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
17 deletions
+48
-17
mysql-test/r/partition_pruning.result
mysql-test/r/partition_pruning.result
+15
-0
mysql-test/t/partition_pruning.test
mysql-test/t/partition_pruning.test
+14
-1
sql/handler.h
sql/handler.h
+2
-2
sql/opt_range.cc
sql/opt_range.cc
+17
-14
No files found.
mysql-test/r/partition_pruning.result
View file @
f2d603c2
...
...
@@ -259,3 +259,18 @@ explain partitions select * from t1 where a is not null;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0,p1 ALL NULL NULL NULL NULL 2 Using where
drop table t1;
create table t1 (a int not null, b int not null, key(a), key(b))
partition by hash(a) partitions 4;
insert into t1 values (1,1),(2,2),(3,3),(4,4);
explain partitions
select * from t1 X, t1 Y
where X.b = Y.b and (X.a=1 or X.a=2) and (Y.a=2 or Y.a=3);
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE X p1,p2 ALL a,b NULL NULL NULL 4 Using where
1 SIMPLE Y p2,p3 ref a,b b 4 test.X.b 2 Using where
explain partitions
select * from t1 X, t1 Y where X.a = Y.a and (X.a=1 or X.a=2);
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE X p1,p2 ALL a NULL NULL NULL 4 Using where
1 SIMPLE Y p1,p2 ref a a 4 test.X.a 2
drop table t1;
mysql-test/t/partition_pruning.test
View file @
f2d603c2
...
...
@@ -230,9 +230,22 @@ create table t1 (a int) partition by hash(a) partitions 2;
insert
into
t1
values
(
1
),(
2
);
explain
partitions
select
*
from
t1
where
a
is
null
;
# this
selects both
# this
uses both partitions
explain
partitions
select
*
from
t1
where
a
is
not
null
;
drop
table
t1
;
# Join tests
create
table
t1
(
a
int
not
null
,
b
int
not
null
,
key
(
a
),
key
(
b
))
partition
by
hash
(
a
)
partitions
4
;
insert
into
t1
values
(
1
,
1
),(
2
,
2
),(
3
,
3
),(
4
,
4
);
explain
partitions
select
*
from
t1
X
,
t1
Y
where
X
.
b
=
Y
.
b
and
(
X
.
a
=
1
or
X
.
a
=
2
)
and
(
Y
.
a
=
2
or
Y
.
a
=
3
);
explain
partitions
select
*
from
t1
X
,
t1
Y
where
X
.
a
=
Y
.
a
and
(
X
.
a
=
1
or
X
.
a
=
2
);
drop
table
t1
;
# No tests for NULLs in RANGE(monotonic_expr()) - they depend on BUG#15447
# being fixed.
sql/handler.h
View file @
f2d603c2
...
...
@@ -567,9 +567,9 @@ class partition_info :public Sql_alloc {
*/
get_subpart_id_func
get_subpartition_id
;
/* NULL-terminated
list
of fields used in partitioned expression */
/* NULL-terminated
array
of fields used in partitioned expression */
Field
**
part_field_array
;
/* NULL-terminated
list
of fields used in subpartitioned expression */
/* NULL-terminated
array
of fields used in subpartitioned expression */
Field
**
subpart_field_array
;
/*
...
...
sql/opt_range.cc
View file @
f2d603c2
...
...
@@ -2246,11 +2246,11 @@ typedef struct st_part_prune_param
/***************************************************************
Following fields are used to store an 'iterator' that can be
used to obtain a set of used artitions.
used to obtain a set of used
p
artitions.
**************************************************************/
/*
Start and end+1 partition "numbers". They can have two meanings depending
depending
of the value of part_num_to_part_id:
of the value of part_num_to_part_id:
part_num_to_part_id_range - numbers are partition ids
part_num_to_part_id_list - numbers are indexes in part_info->list_array
*/
...
...
@@ -2536,7 +2536,7 @@ static uint32 part_num_to_part_id_list(PART_PRUNE_PARAM* ppar, uint32 num)
List<SEL_IMERGE> represents "imerge1 AND imerge2 AND ...".
The set of used partitions is an intersection of used partitions sets
for imerge_{i}.
We accumulate this intersection a separate bitmap.
We accumulate this intersection
in
a separate bitmap.
RETURN
See find_used_partitions()
...
...
@@ -2554,7 +2554,7 @@ static int find_used_partitions_imerge_list(PART_PRUNE_PARAM *ppar,
bitmap_bytes
)))
{
/*
Fallback, process just first SEL_IMERGE. This can leave us with more
Fallback, process just
the
first SEL_IMERGE. This can leave us with more
partitions marked as used then actually needed.
*/
return
find_used_partitions_imerge
(
ppar
,
merges
.
head
());
...
...
@@ -2623,20 +2623,20 @@ int find_used_partitions_imerge(PART_PRUNE_PARAM *ppar, SEL_IMERGE *imerge)
/*
Recursively walk the SEL_ARG tree, find/mark partitions that need to be
used
Collect partitioning ranges for the SEL_ARG tree and mark partitions as
used
SYNOPSIS
find_used_partitions()
ppar Partition pruning context.
key_tree
Intervals tree to perform pruning for.
key_tree
SEL_ARG range tree to perform pruning for
DESCRIPTION
This function
* recursively walks the SEL_ARG* tree collecting partitioning
"intervals";
*
finds the partitions one needs to use to get rows in these intervals;
* marks these partitions as used.
* recursively walks the SEL_ARG* tree collecting partitioning
"intervals"
* finds the partitions one needs to use to get rows in these intervals
*
marks these partitions as used
NOTES
WHAT IS CONSIDERED TO BE "INTERVALS"
A partition pruning "interval" is equivalent to condition in one of the
forms:
...
...
@@ -2687,7 +2687,7 @@ int find_used_partitions(PART_PRUNE_PARAM *ppar, SEL_ARG *key_tree)
{
/*
Partitioning is done by RANGE|INTERVAL(monotonic_expr(fieldX)), and
we got "const1
< fieldX < const2" interval.
we got "const1
CMP fieldX CMP const2" interval
*/
DBUG_EXECUTE
(
"info"
,
dbug_print_segment_range
(
key_tree
,
ppar
->
range_param
.
...
...
@@ -2761,7 +2761,7 @@ int find_used_partitions(PART_PRUNE_PARAM *ppar, SEL_ARG *key_tree)
DBUG_EXECUTE
(
"info"
,
dbug_print_singlepoint_range
(
ppar
->
arg_stack
,
ppar
->
part_fields
););
uint32
part_id
;
/*
then f
ind in which partition the {const1, ...,constN} tuple goes */
/*
F
ind in which partition the {const1, ...,constN} tuple goes */
if
(
ppar
->
get_top_partition_id_func
(
ppar
->
part_info
,
&
part_id
))
{
res
=
0
;
/* No satisfying partitions */
...
...
@@ -2843,7 +2843,10 @@ int find_used_partitions(PART_PRUNE_PARAM *ppar, SEL_ARG *key_tree)
if
(
set_full_part_if_bad_ret
)
{
/* Restore the "used partition iterator" to its default */
/*
Restore the "used partitions iterator" to the default setting that
specifies iteration over all partitions.
*/
ppar
->
part_num_to_part_id
=
part_num_to_part_id_range
;
ppar
->
start_part_num
=
0
;
ppar
->
end_part_num
=
ppar
->
part_info
->
no_parts
;
...
...
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