diff options
author | unknown <sergefp@mysql.com> | 2005-12-29 09:32:46 +0300 |
---|---|---|
committer | unknown <sergefp@mysql.com> | 2005-12-29 09:32:46 +0300 |
commit | 78d1abbaf9c016843c0880edc60d084f5079d9e2 (patch) | |
tree | aba9eff2e71641b913683311e0707cb6cbbabe3e | |
parent | e6bff9a606691c068cc173bc25f8539517e46925 (diff) | |
download | mariadb-git-78d1abbaf9c016843c0880edc60d084f5079d9e2.tar.gz |
WL#2985 "Partition Pruning": post-review fixes: Better comments
mysql-test/r/partition_pruning.result:
WL#2985 "Partition Pruning": more tests
mysql-test/t/partition_pruning.test:
WL#2985 "Partition Pruning": more tests
sql/handler.h:
WL#2985 "Partition Pruning": post-review fixes: comments
-rw-r--r-- | mysql-test/r/partition_pruning.result | 15 | ||||
-rw-r--r-- | mysql-test/t/partition_pruning.test | 15 | ||||
-rw-r--r-- | sql/handler.h | 4 | ||||
-rw-r--r-- | sql/opt_range.cc | 31 |
4 files changed, 48 insertions, 17 deletions
diff --git a/mysql-test/r/partition_pruning.result b/mysql-test/r/partition_pruning.result index a503515e4f1..ef431b2c00e 100644 --- a/mysql-test/r/partition_pruning.result +++ b/mysql-test/r/partition_pruning.result @@ -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; diff --git a/mysql-test/t/partition_pruning.test b/mysql-test/t/partition_pruning.test index 521ebaef35f..0d6bd344159 100644 --- a/mysql-test/t/partition_pruning.test +++ b/mysql-test/t/partition_pruning.test @@ -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. diff --git a/sql/handler.h b/sql/handler.h index eff4ecdc4d2..9c67bb8a1f4 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -567,9 +567,9 @@ public: */ 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; /* diff --git a/sql/opt_range.cc b/sql/opt_range.cc index f3dc96eb868..a2fdea1bf6e 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -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 partitions. **************************************************************/ /* 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 find in which partition the {const1, ...,constN} tuple goes */ + /* Find 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 @@ process_next_key_part: 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; |